题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4279
题意:定义f(x)是大于0小于x中不能被x整除且与x不互质的数的个数,如果x是递增的,则说x是一个real number。
给你两个数x与y ,求出在他们之间的real number数的个数。
Code:
#include <stdio.h>
#include <math.h>
__int64 a,b;
__int64 get(__int64 x)
{
if(x<6)
return 0;
__int64 xx = (__int64)sqrt(x*1.0);
if(xx%2 == 1)
return (__int64)(x/2) -1;
else
return (__int64)(x/2) -2;
}
int main()
{
int ncase;
scanf("%d",&ncase);
while(ncase--)
{
scanf("%I64d%I64d",&a,&b);
printf("%I64d\n",get(b)-get(a-1));
}
return 0;
}