Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 12878 | Accepted: 6359 |
Description
Input
Output
Sample Input
7 12 0
Sample Output
6 4
Source
——————————————————————————
欧拉函数:
#include <stdio.h>
#include<iostream>
using namespace std;
#include <string.h>
int main()
{
int n,m,k,i,j;
int ans;
while(cin>>n&&n)
{
m = n;
for(i = 2,ans = n ; i*i<=n; i++)
{
if(n%i==0)
{
ans=ans *1-ans/i;
do
{
n/=i;
}
while(n%i==0);
}
}
if(n!=1)
ans=ans-ans/n;
if(m==1)
printf("0\n");
else
printf("%d\n",ans);
}
return 0;
}