func_code_string: #include <bits/stdc++.h>   using namespace std;   const double EPS = 1e-8;   int powmod(long long a, int b, int c) {     long long r = 1 % c;     while (b) {       if (b & 0x1) r = r * a % c;       a = a * a % c;       b >>= 1;     }     return r;   }   int phi(int n) {     int ret = n, i;     for (i = 2; i * i <= n; ++i)       if (n % i == 0) {         ret -= ret / i;         while (n % i == 0) n /= i;       }     if (n != 1) ret -= ret / n;     return ret;   }   int eval(char s[]) {     int i, r = 0;     for (i = 0; s[i]; ++i) r = r * 10 + s[i] -  0 ;     return r;   }   char B[1000005], N[1000005];   int C;   void gao() {     long long b = 0, c;     int i;     for (i = 0; B[i]; ++i) b = b * 10 + B[i] -  0 , b %= C;     if (strlen(N) == 1 && N[0] ==  1 ) {       --b;       if (b < 0) b += C;       if (b == 0) b = C;       cout << b << endl;       return;     }     if (strlen(N) <= 9) {       c = eval(N);       --c;     } else {       c = phi(C);       long long t = 0;       for (i = 0; N[i]; ++i) t = t * 10 + N[i] -  0 , t %= c;       --t;       if (t < 0) t += c;       c += t;     }     long long ret = powmod(b, c, C);     ret = ret * (b - 1) % C;     if (ret < 0) ret += C;     if (ret == 0) ret = C;     cout << ret << endl;   }   int main() {     while (3 == scanf( %s%s%d , B, N, &C)) gao();     return 0;   }   