1
// Approach :-> This is question of combination3
// 0 1 2 3 4 5 6 7 8 9 10 11 . . . . . n4
// 5 * 4 * 5 * 4 * 5 * 4 * 5 * 4 * 5 * 4 * 5 * 4 . . . . . n/4 times of 4 and6
// so calculate 5*4 = 20 -------> 20 * 20 * 20 * . . . . .. n/2 times7
// so calcultae pow(20,n/2)8
// if n is even return pow(20,n/2)9
// if n is odd return 5*pow(20,n/2) beacause if n is odd then one 5 is left out10
// we can easily calculate pow(x,y) in log(y) times11
// durign calculation take care about mod15
long long solve(long long val,16
long long pow) { // calculatin pow in log(n) time17
if (pow == 0) return 1;20
return solve((val * val) % mod, pow / 2) % mod;22
return (val * solve((val * val) % mod, pow / 2)) % mod;24
int countGoodNumbers(long long n) {25
// even means 5 options28
long long pow = n / 2; // calculate no of times 5*4 means 20 occurs30
long long ans = solve(20, pow); // calculate power(20,pow)32
if (n % 2 == 0) { // if n is even then 5 and 4 occur same no of time n/235
return ((5 * ans) % mod); // if n is odd then 5 occurs n/2+1 times means one extra times36
// so return ans*5 and don't forgot to mod