#include #include #include #include #include #include std::map Exp; //long *Exp; long getExp(long b, long long int e, long p){ //printf("%lld\n",e); if(e==0){ return 1; } if(/*Exp[e] == -1*/Exp.find(e) == Exp.end()){ //printf("Calculating for e=%lld....\n",e); if(e == 1){ Exp[e] = b % p; } if(e%2 == 0){ long long int val = getExp(b,e/2,p); Exp[e] = ((val % p)*(val % p)) % p; } else{ long long int x = e/2; long long int y = e-x; Exp[e] = ((getExp(b,x,p) % p)*(getExp(b,y,p))) % p; } } return Exp[e]; } int main() { long a,b,p = 1000000007; long long int t; scanf("%ld",&a); scanf("%ld",&b); scanf("%lld",&t); long long int i; /*Exp = (long *)malloc(sizeof(long)*(t+1)); for(i=0;i<=t;i++){ Exp[i]=-1; }*/ long finalfactor = getExp(((a+b)/2),t,p); printf("%ld",finalfactor); /* Enter your code here. Read input from STDIN. Print output to STDOUT */ return 0; }