日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

hdu 1286 找新朋友 欧拉函数模版题

發布時間:2024/9/5 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 hdu 1286 找新朋友 欧拉函数模版题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

找新朋友

Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)

Problem Description 新年快到了,“豬頭幫協會”準備搞一個聚會,已經知道現有會員N人,把會員從1到N編號,其中會長的號碼是N號,凡是和會長是老朋友的,那么該會員的號碼肯定和N有大于1的公約數,否則都是新朋友,現在會長想知道究竟有幾個新朋友?請你編程序幫會長計算出來。

?

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 找新朋友 欧拉函数模版题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。