The program must accept an integer N as the input. The program should determine if the given number is a perfect square. If the number is a perfect square, the program must print YES. Otherwise, the program must print NO.
Boundary Condition(s):
1 <= N <= 10^12
Input Format:
The first line contains the integer N.
Output Format:
The first line contains either YES or NO.
Example Input/Output 1:
Input:
25
Output:
YES
Explanation:
The number 25 is a perfect square of 5. Hence the output is YES.
Example Input/Output 2:
Input:
20
Output:
NO
Explanation:
The number 20 is not a perfect square. Hence the output is NO.
n = int(input().strip())
sqrt_n = int(n**0.5)
print("YES" if sqrt_n*sqrt_n == n else "NO")
#include<stdio.h>
#include<math.h>
int main() {
long long int n;
scanf("%lld", &n);
long long int root = (long long int)sqrt(n);
printf("%s", (root * root == n) ? "YES" : "NO");
return 0;
}
#include <iostream>
#include <cmath>
using namespace std;
int main() {
long long int n;
cin >> n;
long long int root = (long long int)sqrt(n);
cout << ((root * root == n) ? "YES" : "NO");
return 0;
}
import java.util.Scanner;
public class PerfectSquare {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
long sqrtN = (long) Math.sqrt(n);
System.out.println((sqrtN * sqrtN == n) ? "YES" : "NO");
}
}