The Euler function Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description The Euler function phi is an important kind of function in number theory, (n) represents the amount of the numbers which are sm…
题意:给一个N,和公式 求G(N). 分析:设F(N)= gcd(1,N)+gcd(2,N)+...gcd(N-1,N).则 G(N ) = G(N-1) + F(N). 设满足gcd(x,N) 值为 i 的且1<=x<=N-1的x的个数为 g(i,N). 则F(N)  = sigma{ i * g(i,N) }. 因为gcd(x,N) == i 等价于 gcd(x/i, N/i)  == 1,且满足gcd(x/i , N/i)==1的x的个数就是 N/i 的欧拉函数值.所以g(i,N) 的值…
http://poj.org/problem?id=2478 此题只是用简单的欧拉函数求每一个数的互质数的值会超时,因为要求很多数据的欧拉函数值,所以选用欧拉函数打表法. PS:因为最后得到的结果会很大,所以结果数据类型不要用int,改为long long就没问题了 #include <iostream> #include <stdio.h> using namespace std; #define LL long long LL F[]; ]; void phi_table(in…
Description Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go to the market and buy them. Plenty of…
Given the value of N, you will have to find the value of G. The definition of G is given below:Here GCD(i, j) means the greatest common divisor of integer i and integer j.For those who have trouble understanding summation notation, the meaning of G i…
题意:给N个数,求对每个数ai都满足最小的phi[x]>=ai的x之和. 分析:先预处理出每个数的欧拉函数值phi[x].对于每个数ai对应的最小x值,既可以二分逼近求出,也可以预处理打表求. #include<bits/stdc++.h> using namespace std; typedef long long LL; ; int phi[maxn]; int res[maxn]; bool isprime[maxn]; void Euler(){ //欧拉函数筛 ;i<ma…
/* 给定n个数ai,要求欧拉函数值大于ai的最小的数bi 求sum{bi} */ #include<bits/stdc++.h> using namespace std; #define maxn 1000005 int n,a[maxn]; int phi[maxn],m,v[maxn],prime[maxn]; void init(int n){ memset(v,,sizeof v); m=; ;i<n;i++){ ){//i是质数 v[i]=i,prime[++m]=i; ph…
Problem I. Count Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 42    Accepted Submission(s): 16 Problem Description Multiple query, for each n, you need to getn i-1∑ ∑ [gcd(i + j, i - j) = 1…
在一个平面直角坐标系的第一象限内,如果一个点(x,y)与原点(0,0)的连线中没有通过其他任何点,则称该点在原点处是可见的. 例如,点(4,2)就是不可见的,因为它与原点的连线会通过点(2,1). 部分可见点与原点的连线如下图所示: 编写一个程序,计算给定整数N的情况下,满足0≤x,y≤N0≤x,y≤N的可见点(x,y)的数量(可见点不包括原点). 输入格式 第一行包含整数C,表示共有C组测试数据. 每组测试数据占一行,包含一个整数N. 输出格式 每组测试数据的输出占据一行. 应包括:测试数据的…
Description   Given A,B,C, You should quickly calculate the result of A^B mod C. (1<=A,C<=1000000000,1<=B<=10^1000000). Input There are multiply testcases. Each testcase, there is one line contains three integers A, B and C, separated by a sin…