There’re bacterias in the Petri dish. The only thing they can do is to reproduce themselves everyday.
After one bacteria reproduce itself, there will be one origin bacteria and y newborn bacterias.
Suppose there’re x bacterias on the first day.
Your task is to compute how many bacterias on the n-th day.
Please output the answer modulo 10177 because the answer may be too large to be represented by int.
Hint: if you got TLE, try to optimize power by recursion.
#define MOD 10177
// Ch7 Slide P.35
// compute an
int fast_pow(int a, int n){
if( n == 0 ){ // basis
return 1;
}
else{ // resursive
int k = ???;
// if n is even:
// return (k*k)%MOD
// if n is odd:
// return ???
}
}
There are multiple lines of input.
Each line contains 3 positive integers x,y,n
Print the number of bacterias on the n-th day modulo 10177 for each line of input.
Remember ‘\n’ on the end of line.
Explantation of Sample I/O: