#include #include #include #include #include using namespace std; int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int a, b; uint64_t t; cin >> a >> b; cin >> t; uint64_t x= (a + b) / 2; /* ((a + b) / 2)^t is guaranteed to be integer, then since 2 is prime (a + b) % 2 == 0 */ /* Calculate x^t via exponentiation by squaring - O(log(t)) */ uint64_t y= 1; while (t > 1) { if (t % 2 != 0) { t--; y*= x; y%= 1000000007ULL; } x*= x; t/= 2; x%= 1000000007ULL; } x*= y; x%= 1000000007ULL; cout << x << endl; return 0; }