2015
05-23

# Number Theory?

In number theory, for a positive number N, two properties are often mentioned, one is Euler’s function, short for E(N), another is factor number, short for F(N).
To be more precise for newbie, here we recall the definition of E(N) and F(N) again.
E(N) = |{i | gcd(N, i) = 1, 1 <= i <= N}|
F(N) = |{i | N % i = 0, 1 <= i <= N}|
Here |Set| indicates the different elements in the Set.
As a number fanaticism, iSea want to solve a simple problem now. Given a integer N, try to find the number of intervals [l, r], l is no bigger than r obviously, strictly fit in the interval [1, N]. It’s a piece of cake for clever you, of course. But here he also has another troublesome restrict:

The first line contains a single integer T, indicating the number of test cases. Each test case includes one integer N.

Technical Specification
1. 1 <= T <= 1 000
2. 1 <= N <= 1 000 000 000

The first line contains a single integer T, indicating the number of test cases. Each test case includes one integer N.

Technical Specification
1. 1 <= T <= 1 000
2. 1 <= N <= 1 000 000 000

2
2
9

Case 1: 1
Case 2: 6

//[hdu 4215]Number Theory? 数论+打表 by ahm001

#include<cstdio>
#include<cstring>
#define N 30
using namespace std;
int i,o,p,j,k,l,n,m,t,r;
int e[40];
int f[40];
int ans[40];

int gcd(int x,int y)
{
if (y==0) return x;
return gcd(y,x%y);
}

int main()
{
memset(ans,0,sizeof(ans));
memset(e,0,sizeof(e));
memset(f,0,sizeof(f));
for (i=1;i<=N;i++)
for (j=1;j<=i;j++)
{
if (gcd(i,j)==1) ++e[i];
if (gcd(i,j)==j) ++f[i];
}
for (i=1;i<=N;i++)
{
e[i]+=e[i-1];
f[i]+=f[i-1];
}
for (i=1;i<=N;i++)
for (j=i;j<=N;j++)
if(e[j]-e[i-1]==f[j]-f[i-1])
{
ans[j]+=1;
}
for (i=1;i<=N;i++) ans[i]+=ans[i-1];

/*打表 更改N=1000
for (i=1;i<=N;i++)
printf("%d ",ans[i]);
*/
scanf("%d",&t);
p=0;
for (;t;t--)
{
scanf("%d",&i);
printf("Case %d: ",++p);
if (i<=N) printf("%d\n",ans[i]);
else printf("%d\n",ans[N]);
}
return 0;
}

1. ᅍ工厂代发 ++原单BakersRolex(劳力士)Balmain(法国时尚大牌·巴尔曼)Armani(阿玛尼)Karen Walker(凯伦·沃克)ahuo.gq