#define FILE_IN(__fname) freopen(__fname, "r", stdin) #define FILE_OUT(__fname) freopen(__fname, "w", stdout) #define rep(a,s,t,i) for (int a = s; a <= t; a += i) #define repp(a,s,t,i) for (int a = s; a < t; a += i) #define countdown(s) while (s --> 0) #define IMPROVE_IO() std::ios::sync_with_stdio(false)
longlongintfastPower(longlongint x, longlongint a, longlongint p){ longlongint ret = 1; if (a == 0) return x; while (a) { if (a & 1) ret = ret * x % p; x = x * x % p; a >>= 1; } return ret; }
longlongintphi(longlongint x){ longlongint ret = x, a = x; for (longlongint i = 2; i * i <= a; ++i) { if (a % i == 0) { // 如果i是a的质因子 ret = ret / i * (i - 1); while (a % i == 0) a /= i; // 筛去所有的i } } if (a > 1) ret = ret / a * (a - 1); return ret; }