-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy path10299 - Relatives.cpp
39 lines (37 loc) · 982 Bytes
/
10299 - Relatives.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
Royal Flush , AUST
*/
#include <bits/stdc++.h>
#define pb push_back
#define INF 1<<30
#define all(x) x.begin(),x.end()
#define ms(a,v) memset(a,v,sizeof a)
#define II ({int a; scanf("%d", &a); a;})
#define LL ({ll a; scanf("%lld", &a); a;})
#define EPS 1e-10
#define pi acos(0.0)
using namespace std;
typedef long long ll;
#define rep(i,n) for( __typeof(n)i = 0 ; i < n ; i++)
#define For(i,n) for( __typeof(n)i = 1 ; i <= n ; i++)
#define forstl(i,n) for(__typeof(n.begin())i = n.begin();i!=n.end();i++)
#define forab(i,a,b) for( __typeof(b) i = a ; i <= (b) ; i++ )
#define forba(i,b,a) for( __typeof(b) i = b ; i >= (a) ; i-- )
ll phi ( ll n ) {
ll i,res = n ;
for ( i = 2 ; i * i <= n ; ++ i )
if ( n % i == 0 ) {
while ( n % i == 0 )
n /= i ;
res -= res / i ;
}
if ( n > 1 ) res -= res / n ;
return res ;
}
int main(){
ll n ;
while(scanf("%lld",&n) && n ){
if( n == 1 ) puts("0");
else printf("%lld\n",phi(n));
}
}