2015
05-23

# Number

Here are two numbers A and B (0 < A <= B). If B cannot be divisible by A, and A and B are not co-prime numbers, we define A as a special number of B.
For each x, f(x) equals to the amount of x’s special numbers.
For example, f(6)=1, because 6 only have one special number which is 4. And f(12)=3, its special numbers are 8,9,10.
When f(x) is odd, we consider x as a real number.
Now given 2 integers x and y, your job is to calculate how many real numbers are between them.

In the first line there is an integer T (T <= 2000), indicates the number of test cases. Then T line follows, each line contains two integers x and y (1 <= x <= y <= 2^63-1) separated by a single space.

In the first line there is an integer T (T <= 2000), indicates the number of test cases. Then T line follows, each line contains two integers x and y (1 <= x <= y <= 2^63-1) separated by a single space.

2
1 1
1 10

0
4
Hint For the second case, the real numbers are 6,8,9,10.  

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>

using namespace std;
typedef long long LL;

LL Solve(LL n)
{
LL ans=0;
if(n<6) return 0;
ans+=n/2-2;
if((LL)sqrt(1.0*n)&1) ans++;
return ans;
}

int main()
{
LL a,b,t;
cin>>t;
while(t--)
{
cin>>a>>b;
cout<<Solve(b)-Solve(a-1)<<endl;
}
return 0;
}


1. 我觉得 朝颜其实活得挺累的，从小，便是三姐妹中的老大，被姐妹被同伴背叛，爱上了自己不该爱的吸血鬼，妹妹一个变成了吸血鬼，一个还生死不明（朝颜的角度）。