操人视频99青青av|亚洲a极淫交3P毛片电影|精品蜜桃人妻天天久|国产精品色婷婷免费|正规av网站在线免费观看|国产精品高清在线观看|免费成人网站在线|97干色五月天最黄三级无码片|在线免费观看黄色毛片A片|日韩无码视频一二三四区

POJ 2407 Relatives && UVA 10299 Relative -電腦資料

電腦資料 時間:2019-01-01 我要投稿
【www.emoneyp.cn - 電腦資料】

    【題目大意】:歐拉函數(shù):求少于或等于n的數(shù)中與n互素的數(shù)的個數(shù);n <= 1,000,000,000,

POJ 2407 Relatives && UVA 10299 Relative

。

    【思路】:裸歐拉函數(shù),注意特判n==1的情況,n==1的情況下,應該輸出0,poj依然判斷1也可以過,但是老牌ojUVA必須是0才過,注意一下。

    代碼:

#include<stdio.h>#include<string.h>#include<iostream>#include using namespace std;typedef long long LL;int eular(int n){    int res=n;    for(int i=2; i*i<=n; ++i){        if(n%i==0){            n/=i;res=res-res/i;            while(n%i==0)            {                n/=i;            }        }    }    if(n!=1) res=res-res/n;    return res;}int main(){    int n;while(cin>>n&&n!=0)    {        if(n==1) puts("0");        else printf("%d\n",eular(n));    } return 0;}</iostream></string.h></stdio.h>

    版權聲明:本文為博主原創(chuàng)文章,未經(jīng)博主允許不得轉載,

電腦資料

POJ 2407 Relatives && UVA 10299 Relative》(http://www.emoneyp.cn)。

最新文章