#include #include #include #include #include #include #include using namespace std; int modulo_exponent(long long int b, long long int e, long long int m){ //Return (b^e)%m long long int half_exp; long long int big_num, big_num_mod, big_num_mod_b; if (e==0) return 1; half_exp = modulo_exponent(b, e/2, m); //cout << b << "^" << e/2 << "%" << m << "=" << half_exp << endl; big_num = (half_exp * half_exp); big_num_mod = big_num % m; big_num_mod_b = (b* big_num_mod)%m; // cout << "(" << b << "^" << e/2 << "%" << m << ") squared =" << big_num << endl; //cout << "(" << b << "^" << e/2 << "%" << m << ") squared % m =" << big_num_mod << endl; if (e%2 == 0) return big_num_mod; else return big_num_mod_b; } int main() { int a, b; long long int t; int modulo = 1000000007; cin >> a >> b >> t; double avg_growth = ((a*1.0)+(b*1.0))/2.0; cout << modulo_exponent(avg_growth, t, modulo); return 0; }