Problem Author: | Hasan Saleh (MathModel) |
Prepared by: | Hasan Saleh (MathModel) |
Edited by: | Hasan Saleh (MathModel) |
Solution
By the basic counting principle , for some set of elements having choices of c_1,c_2,...,c_n , and each element choices are independent then the number of total choices is \displaystyle \prod_{i=1}^n c_i = c_1 \cdot c_2 \cdot c_3 ... \cdot c_n , The same can be applied here.
For each digit , let the number of possible choices , compute this for each 0 \le d \le 9 and then the answer will be :
def solve():
n=int(input())
x=input()
choice=[1,4,4,2,4,1,2,1,4,1]
ans=1
for i in x:
ans*=choice[int(i)]
ans%=(999983)
print(ans%(999983))
for _ in range(int(input())):
solve()
Complexity .