Question is this
Nancy hates any and every string that contains the number "13". Clouseau wants to gift her a string and is looking over his options, ofcourse he would never pick a string that has "13" as a substring.
Tell Clouseau the total number of such strings s that are made of exactly N characters. The strings may contain any integer from 0-9, repeated any number of times.
Input : The first line of input file contains a number T indicating number of test cases. The following T lines, each contain an integer N.
Output : The output file should contain answer to each query in a new line modulo 1000000009.
Constraints : 1 T 100000 , 0 N 1000000009
I am not getting the logic correct.
# include <stdio.h>
# define MOD 1000000009
unsigned long long mod_pow(unsigned long long num, unsigned long long pow, unsigned long long mod)
{
unsigned long long test;
unsigned long long n = num;
for(test = 1; pow; pow >>= 1) {
if (pow & 1)
test = ((test % mod) * (n % mod)) % mod;
n = ((n % mod) * (n % mod)) % mod;
}
return test;
}
int main(int argc, char* argv[])
{
long t;
unsigned long long total_no, bad_no, n;
scanf ("%ld", &t);
while (t--) {
scanf ("%lld", &n);
if (n != 1) {
total_no = (10 * (mod_pow (10, n-1, MOD))) % MOD;
bad_no = ((n - 1) * (mod_pow(10, n-2, MOD))) % MOD;
printf ("%lld\n", (((total_no - bad_no) % MOD)));
}
else
printf ("10\n");
}
return 0;
}