hdu 1286 找新朋友 欧拉函数模版题
生活随笔
收集整理的這篇文章主要介紹了
hdu 1286 找新朋友 欧拉函数模版题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
找新朋友
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)
?
Input 第一行是測試數據的組數CN(Case number,1<CN<10000),接著有CN行正整數N(1<n<32768),表示會員人數。?
Output 對于每一個N,輸出一行新朋友的人數,這樣共有CN行輸出。?
Sample Input 2 25608 24027?
Sample Output 7680 16016?
Author SmallBeer(CML)?
Source 杭電ACM集訓隊訓練賽(VII) 思路:歐拉函數模版題; #include<iostream> #include<cstdio> #include<cmath> #include<string> #include<queue> #include<algorithm> #include<stack> #include<cstring> #include<vector> #include<list> #include<set> #include<map> using namespace std; #define ll __int64 #define mod 1000000007 #define inf 999999999 //#pragma comment(linker, "/STACK:102400000,102400000") int scan() {int res = 0 , ch ;while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) ){if( ch == EOF ) return 1 << 30 ;}res = ch - '0' ;while( ( ch = getchar() ) >= '0' && ch <= '9' )res = res * 10 + ( ch - '0' ) ;return res ; } int phi(int n) {int i,rea=n;for(i=2;i*i<=n;i++){if(n%i==0){rea=rea-rea/i;while(n%i==0) n/=i;}}if(n>1)rea=rea-rea/n;return rea; } int main() {int T;scanf("%d",&T);while(T--){int x;scanf("%d",&x);printf("%d\n",phi(x));}return 0; } View Code?
轉載于:https://www.cnblogs.com/jhz033/p/5463483.html
總結
以上是生活随笔為你收集整理的hdu 1286 找新朋友 欧拉函数模版题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: HTML5文档结构 摘要
- 下一篇: 软件项目风险管理介绍