import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class NumOfSqrs {
public static void main(String[] args) {
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input;
int line = 0;
int testCases;
int numOfSqrt = 0;
int j = 0;
while((input=br.readLine())!=null){
if(line == 0){
testCases = Integer.parseInt(input);
line = line +1;
}
else{
String[] splitter = input.toString().split(" ");
for(int i = Integer.parseInt(splitter[0]); i<=Integer.parseInt(splitter[1]) ; i++){
String value = ""+Math.sqrt(i);
String[] isSqrt = value.toString().split("\\.");
if(isSqrt[1].length() == 1){
numOfSqrt++;
}
}
System.out.println(""+numOfSqrt);
}
numOfSqrt = 0;
}
}catch(IOException io){
io.printStackTrace();
}
}
}
Wednesday, 6 September 2017
finding perfect squares
Subscribe to:
Post Comments (Atom)
test your brain
https://www.youtube.com/watch?v=bEU9dkOG7co&feature=youtu.be
-
https://www.youtube.com/watch?v=bEU9dkOG7co&feature=youtu.be
-
public class Strecke { Punkt p1, p2; Strecke (Punkt punkt1, Punkt punkt2) { this.p1 = punkt1; this.p2 = punkt2;...
-
import java.util.Scanner; public class example { static int reverseNumber(int number) { int reverse = 0; ...
No comments:
Post a Comment