We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public class Solution {
public static boolean isSmartNumber(int num) {
int val = (int) Math.sqrt(num);
if(num / val == 1)
return true;
return false;
}
public static void main(String[] args) {
int test_cases;
Scanner in = new Scanner(System.in);
test_cases = in.nextInt();
int num;
for(int i = 0; i < test_cases; i++){
num = in.nextInt();
boolean ans = isSmartNumber(num);
if(ans){
System.out.println("YES");
}
else System.out.println("NO");
}
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Smart Number
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution { public static boolean isSmartNumber(int num) { int val = (int) Math.sqrt(num);
if(num / val == 1) return true; return false; }
}