Http://acm.hust.edu.cn/vjudge/problem/31861/origin
The topic asks for a number n, removes its approximate number from "1,n", and removes all its coprime numbers, the number of remaining numbers, if the number is odd, is a real
Find the number of real numbers between the interval "x, y"
First of all the rules of the table found, in fact, also good proof:
First for a number, and its coprime number must be an even number (according to the Euler formula can be obtained), and secondly for the approximate, only the square number of the approximate is odd, the rest are even,
If the number is not a square number
num = N-euler (n)-divisor (n) +1, that is, even non-squared numbers are real number, plus 1 is because 1 even if coprime is also a factor
If it is squared, then only odd squares are real number
If you ask for "1,x" How many real number, first ask how many even, and then subtract even square number Achieva medical number of square number
The even number is N/2, odd squares and even squares, if sqrt (n)%2, the odd number is one, otherwise
Note that sqrt (1.0*n) will explode, sqrt ((double) n) will explode, only sqrt ((Long long Doubel) n) will not
or int x=sqrt (n), if (x*x>n) x--;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
# Include <algorithm>
#include <queue>
#include <map>
#include <set>
# Include <vector>
#include <iostream>
using namespace std;
Const double Pi=acos ( -1.0);
Double eps=0.000001;
int num[]= {0,0,0,0,0,0,1,1,2,3};
Long Long cal1 (long long N)
{
if (n<=4)
return 0;
Long Long ans= (n-4)/2;
Long Long tmp=sqrt (n);
if (tmp*tmp>n)
tmp--;
if (tmp%2)
ans++;
return ans;
}
int main ()
{
int t;
cin>>t;
while (t--)
{
long long x, y;
scanf ("%lld%lld", &x,&y);
Long Long ret1=cal (x-1);
Long long ret2=cal (y);
printf ("%lld\n", Ret2-ret1);
}
return 0;
}