#include using namespace std; int pow(unsigned x, unsigned long y, unsigned long M, int res = 1) { x = x % M; // reduce and update x if appropriate while (y) { if (y & 1) // res = (res * x) % M; res = ((res % M) * (x % M)) % M; y >>= 1; x = ((x % M) * (x % M)) % M; // x = (x * x) % M; } return res; } int main() { unsigned a, b; unsigned long t, divisor = 1000000007; cerr << divisor << endl; cin >> a >> b >> t; // Compute [ (a+b)/2 ]^t * numCells % p cout << pow((a + b) / 2, t, divisor) << endl; }