#include #include #include #include #include using namespace std; long long modulo = pow(10,9) +7; long long efficientExp(long long base, long long power) { if (power == 1) { return base % modulo; } if (power % 2 == 0) { //log 2 speed yay! return efficientExp(base*base % modulo, power/2); } else { return efficientExp(base, power-1)*base % modulo; } } int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ // Input long long t; long long a; long long b; cin >> a; cin >> b; cin >> t; // Output + Algorithm - ((a+b)/2)^t % (10^9+7) long long growthRate = (a+b)/2; //Should always be an integer. long long cells = efficientExp(growthRate, t); cout << to_string(cells); return 0; }