Test instructions: Ask in a circular mirror, emit a light source from any point, the number of cases where the N-times reflect back to the starting point.
Solution: Direct Sticking ...
Find the number of coprime in n+1 and n+1, i.e. Euler function.
Code:
#include <stdio.h> #include <iostream> #include <algorithm> #include <string> #include < string.h> #include <math.h> #include <limits.h> #include <time.h> #include <stdlib.h># include<map> #include <queue> #include <set> #include <stack> #include <vector> #define LL Long longusing namespace Std;int eular (int n) { int ret = 1; for (int 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 () { int T; while (~SCANF ("%d", &t)) { while (t--) { int n; scanf ("%d", &n); printf ("%d\n", Eular (n + 1)); } } return 0;}
HDU 5430 Reflect