才会拓展欧拉定理太菜了qwq
具体:http://blog.csdn.net/ez_yww/article/details/76176970
这题直接套就好
#include
using namespace std;
typedef long long ll;
int phi(int x){
int ans = x;
for (int i = 2; i * i <= x; i ++)
if (x % i == 0){
ans = 1LL * ans * (i - 1) / i;
while (x % i == 0) x /= i;
}
if (x != 1) ans = 1LL * ans * (x - 1) / x;
return ans;
}
int pw(int x, int i, int mod){
int k = x, ans = 1;
while (i){
if (i & 1) ans = 1LL * ans * k % mod;
k = 1LL * k * k % mod;
i >>= 1;
}
return ans;
}
int f(int p){
if (p == 1) return 0;
return pw(2,f(phi(p)) + phi(p), p);
}
int main(){
int T; scanf("%d", &T);
while (T --){
int n; scanf("%d", &n);
printf("%d\n", f(n));
}
return 0;
}