HEU 1008 Relatives
1
/**************************************
2
Problem HEU 1008 Relatives
3
Time 0.0080s
4
Memory 236 k
5
Accepted Time 2009-03-21 21:28:24
6
Tips 欧拉函数 http://acm.hrbeu.edu.cn/forums/index.php?showtopic=2181&hl=1008
7
**************************************/
8
#include <stdio.h>
9
int main()
10
{
11
long n,i;
12
while(scanf("%ld",&n),n!=0)
13
{
14
long sum=1;
15
for(i=2;;i++)
16
{
17
if(n%i==0)
18
{
19
sum*=i-1;
20
n/=i;
21
while(n%i==0)
22
{
23
n/=i;
24
sum*=i;
25
}
26
}
27
if(n==1)break;
28
}
29
printf("%ld\n",sum);
30
}
31
return 0;
32
}
33
/**************************************2
Problem HEU 1008 Relatives3
Time 0.0080s4
Memory 236 k 5
Accepted Time 2009-03-21 21:28:246
Tips 欧拉函数 http://acm.hrbeu.edu.cn/forums/index.php?showtopic=2181&hl=1008 7
**************************************/8
#include <stdio.h>9
int main()10
{11
long n,i;12
while(scanf("%ld",&n),n!=0)13
{14
long sum=1;15
for(i=2;;i++)16
{17
if(n%i==0)18
{19
sum*=i-1;20
n/=i;21
while(n%i==0)22
{23
n/=i;24
sum*=i;25
}26
}27
if(n==1)break;28
}29
printf("%ld\n",sum);30
}31
return 0;32
}33




浙公网安备 33010602011771号