nyoj 333 mdd的烦恼

题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=333

#include 
#include 
#include 

using namespace std;

int Slove_Euler(int n)
{
    int i, res;
    res = n;
    for(i = 2; i*i <= n; ++i)
    {
        if(n%i == 0)
        {
            res = res/i*(i-1);
            while(n%i == 0)
                n /= i;
        }
    }
    if(n != 1)
        res = res/n*(n-1);
    return res;
}


int main()
{
    int n;
    while(~scanf("%d", &n))
        printf("%d\n", Slove_Euler(n));
    return 0;
}


你可能感兴趣的:(Nyoj,数论,数学题)