Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Solution {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int t = sc.nextInt();
- long a, b;
- for(int i = 1; i <= t; i++)
- {
- a = sc.nextLong();
- b = sc.nextLong();
- int at = (int)(Math.sqrt(a));
- int bt = (int)(Math.sqrt(b));
- long count = 0;
- for(;at <= bt;)
- {
- long temp = at*at;
- if(temp >= a & temp<=b)
- {
- count++;
- }
- at++;
- }
- System.out.println(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement