Bzoj-2705 Longge的问题 欧拉函数
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2705
题意: 求 sigma(gcd(i,n), 1<=i<=n<2^32)
只有一组数据,很好搞,答案就是sigma(phi(n/d)),直接搜就行了。
//STATUS:C++_AC_8MS_11284KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
//#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef long long LL;
typedef unsigned long long ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
const LL LNF=1LL<<;
const double EPS=1e-;
const double OO=1e15;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End LL p[N][];
LL ans,n,cnt; void dfs(LL d,LL phi)
{
if(d==cnt){
ans+=phi;
return ;
}
dfs(d+,phi);
phi=phi/p[d][]*(p[d][]-);
for(int i=;i<=p[d][];i++)
dfs(d+,phi);
} int main(){
// freopen("in.txt","r",stdin);
int i,j,la;
LL t;
scanf("%lld",&n);
cnt=;
for(t=n,i=;i*i<=t;i++){
if(t%i==){
p[cnt][]=i;
while(t%i==){
p[cnt][]++;
t/=i;
}
cnt++;
}
}
if(t)p[cnt][]=t,p[cnt][]=,cnt++; ans=;
dfs(,n); printf("%lld\n",ans);
return ;
}
Bzoj-2705 Longge的问题 欧拉函数的更多相关文章
- BZOJ 2705: [SDOI2012]Longge的问题 [欧拉函数]
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 2553 Solved: 1565[Submit][ ...
- Bzoj 2705: [SDOI2012]Longge的问题 欧拉函数,数论
2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 1959 Solved: 1229[Submit][ ...
- 【bzoj2705】[SDOI2012]Longge的问题 欧拉函数
题目描述 Longge的数学成绩非常好,并且他非常乐于挑战高难度的数学问题.现在问题来了:给定一个整数N,你需要求出∑gcd(i, N)(1<=i <=N). 输入 一个整数,为N. 输出 ...
- poj 2480 Longge's problem [ 欧拉函数 ]
传送门 Longge's problem Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7327 Accepted: 2 ...
- bzoj 2190 [SDOI2008]仪仗队(欧拉函数)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2190 [题意] n*n的正方形,在(0,0)格点可以看到的格子数目. [思路] 预处理 ...
- bzoj 1408 [Noi2002]Robot(欧拉函数)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1408 [题意] 求m的所有约数中,满足可以分解成(奇数个不同素数/偶数个不同素数/其 ...
- Bzoj 2818: Gcd 莫比乌斯,分块,欧拉函数,线性筛
2818: Gcd Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 3241 Solved: 1437[Submit][Status][Discuss ...
- BZOJ2705: [SDOI2012]Longge的问题(欧拉函数)
题意 题目链接 Sol 开始用反演推发现不会求\(\mu(k)\)慌的一批 退了两步发现只要求个欧拉函数就行了 \(ans = \sum_{d | n} d \phi(\frac{n}{d})\) 理 ...
- BZOJ 2818 GCD 素数筛+欧拉函数+前缀和
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2818 题意:给定整数N,求1<=x,y<=n且Gcd(x,y)为素数的数对( ...
- 【BZOJ】2818: Gcd(欧拉函数+质数)
题目 传送门:QWQ 分析 仪仗队 呃,看到题后感觉很像上面的仪仗队. 仪仗队求的是$ gcd(a,b)=1 $ 本题求的是$ gcd(a,b)=m $ 其中m是质数 把 $ gcd(a,b)=1 $ ...
随机推荐
- uva 10056
概率 Q += p*pow(1-p, i*n+k-1) i = 0,1,2,3...... #include <cstdio> #include <cmath> int mai ...
- Android支付接入(四):联通VAC计费
原地址:http://blog.csdn.net/simdanfeg/article/details/9012031 注意事项: 1.联通支付是不需要自己标识软硬计费点的,当平台申请计费点的时候会提交 ...
- linux 使用文本编辑器编写shell脚本执行权限不够
在linux下,自己编写的脚本需要执行的时候,需要加上执行的权限 解决方式:chmod 777 test.sh
- linux mysql为root用户初始化密码和改变root密码
初始化密码: 由于安装MySQL完后,MySQL会自动提供一个不带密码的root用户,为了安全起见给root设置密码: #mysqladmin -u root password 123 (123为密码 ...
- struts2 request内幕 为什么在struts2用EL表达式可以取值
不知道大家有没有想过这样一个问题:为什么在action中的实例变量,没有使用request.setAttribute()方法将值添加到request范围内,却能在jsp中用EL表达式取出? 众所周知, ...
- 转--利用函数模板技术,写一个简单高效的 JSON 查询器
http://www.cnblogs.com/index-html/archive/2012/07/18/js_select.html http://www.ibm.com/developerwork ...
- WinAPI你知道多少?!(上千个,好多都没见过)
http://www.cnblogs.com/vanver/archive/2013/06/13/NO-2013_06_13pm.html 播客开篇,讲讲废话:本篇播客只是推荐给热与钻研的同学们... ...
- Android:Style和Theme
在Web开发中,Html负责内容,CSS负责表现.同样,在Android开发中,可以使用Theme.Style+UI组件的方式实现内容和形式的分离. Style是针对窗体元素级别的,改变指定控件或者L ...
- Android在java代码中设置margin
我们平常可以直接在xml里设置margin,如: <ImageView android:layout_margin="5dip" android:src="@dra ...
- Android ImageView(纯java)
import android.app.Activity; import android.graphics.*; import android.graphics.drawable.*; import a ...