/*Given a number A. Return square root of the number if it is perfect square
otherwise return -1.
Note: A number is a perfect square if its square root is an integer. */
import java.util.* ;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in) ;
int A = scn.nextInt();
int result = solve(A);
System.out.print(result);
}
public static int solve(int A) {
if (A <=0 ) return 0 ;
int sqrtA= (int) Math.sqrt(A);
for (int i=1 ; i<=sqrtA ; i++ )
{
if (A == i*i) return 1;
}
return 0;
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: