-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSquare Number.cpp
More file actions
64 lines (52 loc) · 1022 Bytes
/
Square Number.cpp
File metadata and controls
64 lines (52 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//partially accepted removed, please refer the previous commit to see where I went wrong
/*
Given a number N. Your task is to find out N is Square Number or not.
Square Number is an integer that is the square of an integer, in other words, it is the product of some integer with itself. For example, 16 is a square number, since it can be written as 4 × 4.
Input:
Input contains a single integer N.
Output:
Print YES if N is Square Number else print NO.
Constraints:
Test Files 1 to 5
1<=N<=103
Test Files 6 to 10
1<=N<= 1010
Sample Input #1:
20
Sample Output #1:
NO
Sample Input #2:
36
Sample Output #2:
YES
SAMPLE INPUT
25
SAMPLE OUTPUT
YES
*/
#include <iostream>
#include <math.h>
using namespace std;
bool issquare(long long int n)
{
if(n<0)
{
return false;
}
long int root(round(sqrt(n)));
return (n == root*root);
}
int main()
{
long long int n;
cin>>n;
if(issquare(n))
{
cout<<"YES";
}
else
{
cout<<"NO";
}
return 0;
}