using System; using System.Collections.Generic; using System.IO; using System.Numerics; class Solution { static void Main(String[] args) { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution */ string[] arr = Console.ReadLine().Split(' '); BigInteger sum = (int.Parse(arr[0]) + int.Parse(arr[1]))/2; BigInteger exp = BigInteger.Parse(arr[2]); Console.WriteLine(modpow(sum, exp, 1000000007)); } static BigInteger modpow(BigInteger sum, BigInteger exponent, BigInteger modulus) { BigInteger result = 1; while (exponent > 0) { if ((exponent & 1) == 1) { // multiply in this bit's contribution while using modulus to keep result small result = (result * sum) % modulus; } // move to the next bit of the exponent, square (and mod) the base accordingly exponent >>= 1; sum = (sum * sum) % modulus; } return result; } }