#include #include #include #include #include using namespace std; #define MODULO 1000000007 int refresh_val(int c) { int i = (int)(log(MODULO)/log(c)); i = (abs(log(MODULO)/log(c) - (int)(log(MODULO)/log(c)))) > 0 ? i+1 : i; // cout << "func " << abs(log(MODULO)/log(c) - (int)(log(MODULO)/log(c))) << endl; return i; } int main() { int a, b, ms, c, c0; cin >> a >> b >> ms; // cout << (int)(log(26)/log(3)) << endl; bool not_done = true; int aux = 0; int i = 1; c = 0.5*a + 0.5*b; c0 = c; // cout << c << endl; // while(aux < MODULO && i <= ms) // { // aux = pow(c, i); // done = i == ms ? true : false; // i = aux < MODULO ? i+1 : i; // } // cout << "calc " << ((int)(log(15)/log(2))+1) << " i = " << i << endl; // i = (int)(log(MODULO)/log(c)); // i = (log(MODULO)/log(c) - (int)(log(MODULO)/log(c))) > 0 ? i+1 : i; i = refresh_val(c); // cout << "i " << i << endl; // if (done) // { // cout << i << " " << aux%MODULO << endl; // } // else // { // aux = aux%MODULO; // cout << "ms/i " << (int)(ms/i) << endl; // cout << "restante " << (ms - (int)(ms/i)*i) << endl; // // cout << "cell rest " << pow(aux, (ms - (int)(ms/i)*i)) << endl; // } int aux1=0; i = refresh_val(c); if(i < ms) { aux = pow(c, i); aux = aux % MODULO; ms = (ms - (int)(ms/i)*i); aux1 = pow(c, ms); aux1 = aux1 % MODULO; aux = aux * aux1; aux = aux % MODULO; } else { aux = pow(c, ms); aux = aux % MODULO; } cout << aux << endl; return 0; }