You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
#include <cstdio>
|
|
const int N = 1 << 16 | 1;
|
|
int phi[N];
|
|
int main()
|
|
{
|
|
for (int i = 2; i < N; i++) if (!phi[i])
|
|
for (int j = i; j < N; j += i)
|
|
{
|
|
if (!phi[j]) phi[j] = j;
|
|
phi[j] = phi[j] / i * (i - 1);
|
|
}
|
|
for (int p; ~scanf("%d", &p);)
|
|
printf("%d\n", phi[p - 1]);
|
|
return 0;
|
|
} |