Extremely Dangerous Virus

  • + 0 comments

    static int solve(int a, int b, long t) {

        if(t == 1)return (int) ((a + b) / 2);
    
        return (int)pow((a+b)/2,t);
    }
    static long pow(long avg, long t) {
        long x = 1, n = avg;
        while(t > 0) {
            if(t%2 == 1) {
                x=(x * n)%1000000007;
            }
            n = (n * n)%1000000007;
            t /= 2;
        }
        return x;
    }