标签:style blog http color os io ar for art
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=291 http://acm.nyist.net/JudgeOnline/problem.php?pid=333
思路:欧拉函数的应用,详解见这里:http://blog.csdn.net/once_hnu/article/details/6302868 好文章
直接贴代码:
#include <iostream> #include <cstring> using namespace std; int euler(int x) { int res = x; int a = x; for(int i=2;i*i<=a;i++) { if(a%i==0) res = res/i*(i-1); while(a%i==0) a /= i; } if(a>1) res = res/a*(a-1); return res; } int main() { int n; int res; while(cin>>n) { cout<<euler(n)<<endl; } return 0; }
NYOJ 333 mdd的烦恼&&NYOJ 291 LK的数学题
标签:style blog http color os io ar for art
原文地址:http://www.cnblogs.com/ltwy/p/3945326.html