Hang give you a function f(x).
If x < 10 f(x) = x.
If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);
And ai(0<=i<=9) can only be 0 or 1 .
Give you a0 ~a9,two integer k,m,outf(k)%m
Maybe you should use integer for 64 bits,please use %I64d
出题人英语四级没过,看不懂就下一题
Mutiple test cases
In each case, there will be two lines.
In the first line , there are two positive integers k and m. ( k<2e9 , m<1e5 )
In the second line , there are ten integers a0 ~ a9.
10 9999 1 1 1 1 1 1 1 1 1 1 20 500 1 0 1 0 1 0 1 0 1 0
45 104