/** * https://www.hackerrank.com/contests/rookierank/challenges/extremely-dangerous-virus * All Contests RookieRank Extremely Dangerous Virus */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Solution { public static void main(String[] args) throws NumberFormatException, IOException { FasterScanner sc = new FasterScanner(System.in); long aGrowthFactor = sc.nextLong(); long bGrowthFactor = sc.nextLong(); long a = (aGrowthFactor + bGrowthFactor) / 2; long tNumberOfPeriods = sc.nextLong(); long series = 1; // population = growth ^ time series = myPower(a, tNumberOfPeriods); System.out.println(series); sc.close(); } static long myPower(long base, long exponent) { long result = 1; long M = 1000000007; // calculate the power using the squares method. while (exponent > 0) { if ((exponent & 1) == 1) { // found a power of 2 in the exponent result = (result * base) % M; } // next power of 2 exponent >>= 1; base = (base * base) % M; } return result; } /** Buffered replacement for the java.util.Scanner */ static class FasterScanner { private static BufferedReader _reader; private static StringTokenizer _parser; public FasterScanner(InputStream input) { _reader = new BufferedReader(new InputStreamReader(input)); _parser = new StringTokenizer(""); } /** * Get the next string token from the buffer. */ public String next() throws IOException { while (!_parser.hasMoreTokens()) { _parser = new StringTokenizer(_reader.readLine()); } return _parser.nextToken(); } /** * Get the next line of text from the buffer. */ public String nextLine() throws IOException { try { return _reader.readLine(); } catch (IOException ex) { return null; } } /** * Get the next int from the buffer. */ public int nextInt() throws NumberFormatException, IOException { return Integer.parseInt(next()); } /** * Get the next long from the buffer. */ public long nextLong() throws NumberFormatException, IOException { return Long.parseLong(next()); } /** * Close the scanner. */ public void close() throws IOException { _parser = null; if (_reader != null) { _reader.close(); _reader = null; } } } }