Advertisement
Guest User

Untitled

a guest
Sep 1st, 2014
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Solution {
  5.  
  6. public static void main(String[] args) {
  7. Scanner sc = new Scanner(System.in);
  8. int t = sc.nextInt();
  9. long a, b;
  10. for(int i = 1; i <= t; i++)
  11. {
  12. a = sc.nextLong();
  13. b = sc.nextLong();
  14. int at = (int)(Math.sqrt(a));
  15. int bt = (int)(Math.sqrt(b));
  16. long count = 0;
  17. for(;at <= bt;)
  18. {
  19. long temp = at*at;
  20. if(temp >= a & temp<=b)
  21. {
  22. count++;
  23. }
  24. at++;
  25. }
  26. System.out.println(count);
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement