重囗另类BBWSeⅹHD,av狼论坛,精品一卡2卡三卡4卡乱码理论,体育生gv老师浪小辉3p警察

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

電腦資料 時間:2019-01-01 我要投稿
【www.ipr-jzsc.com - 電腦資料】

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

POJ 2407 Relatives && UVA 10299 Relative

    【思路】:裸歐拉函數,注意特判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>

    版權聲明:本文為博主原創文章,未經博主允許不得轉載,

電腦資料

POJ 2407 Relatives && UVA 10299 Relative》(http://www.ipr-jzsc.com)。

最新文章
主站蜘蛛池模板: 辉县市| 普陀区| 唐海县| 叙永县| 敦化市| 信宜市| 邳州市| 林西县| 龙陵县| 彭山县| 昭苏县| 察雅县| 达拉特旗| 东阿县| 台南县| 阿图什市| 金门县| 承德县| 汤原县| 苏尼特右旗| 剑川县| 长顺县| 会同县| 中超| 黄骅市| 焉耆| 牙克石市| 西昌市| 汝州市| 花莲县| 油尖旺区| 磐石市| 工布江达县| 绩溪县| 怀安县| 镇平县| 台湾省| 古丈县| 德州市| 华坪县| 仙居县|