Created
April 8, 2015 14:10
-
-
Save lackofdream/1715aa8a2629c6180804 to your computer and use it in GitHub Desktop.
HDU1286
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <vector> | |
#include <cstring> | |
#include <stack> | |
#include <queue> | |
#include <algorithm> | |
#include <cmath> | |
#include <cstdlib> | |
#include <ctime> | |
#define sd(x) scanf("%d",&x) | |
#define sdd(x,y) scanf("%d%d",&x,&y) | |
#define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z) | |
#define slflf(x,y) scanf("%lf%lf",&x,&y) | |
#define MAX(a,b) (a>b?a:b) | |
#define MIN(a,b) (a<b?a:b) | |
using namespace std; | |
int eular(int n) | |
{ | |
int ret = 1, i; | |
for (i = 2; i * i <= n; i++) | |
if (n % i == 0) | |
{ | |
n /= i; | |
ret *= (i - 1); | |
while (n % i == 0) | |
{ | |
n /= i; | |
ret *= i; | |
} | |
} | |
if (n > 1) | |
ret *= (n - 1); | |
return ret; | |
} | |
int main(void) | |
{ | |
int t; | |
sd(t); | |
while (t--) | |
{ | |
int n; sd(n); | |
printf("%d\n", eular(n)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment