Logo
(追記) (追記ここまで)

23862번 - Digidivisible Numbers 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB0000.000%

문제

Let's call a number digidivisible in base $B,ドル if it is divisible by all digits in its base $B$ representation. For example, 728ドル_{10}$ is divisible by 7ドル,ドル 2ドル$ and 8ドル,ドル so it is digidivisible in base 10ドル,ドル and number 264ドル_8 = 180_{10}$ is divisible by 2ドル,ドル 6ドル$ and 4ドル,ドル so it is digidivisible in base 8ドル$.

You are given integers $B$ and $n,ドル and some set of allowed digits from 1ドル$ to $B-1$. Find the number of digidivisible numbers consisting of $n$ digits in base $B,ドル only containing these allowed digits. Solve this problem for some fixed $n$ and $B$ and for multiple sets of allowed digits.

입력

The first line contains two integers $B$ and $n$ (2ドル \le B \le 10$; 1ドル \le n \le 10^9$). The second line contains an integer $t$ (1ドル \le t \le 2^{B-1} - 1$) --- the number of sets of allowed digits you need to solve this problem for.

Then, $t$ lines follow, $i$-th line contains a single string $s_i,ドル consisting of $B$ zeros and ones. If $s_{i,k} = 1$ (indices begin with 0), then digit $k$ is allowed, otherwise digit $k$ is forbidden. Each set has at least one allowed digit, and digit 0ドル$ is always forbidden. All $t$ sets are distinct.

출력

For each one of the $t$ sets print the answer in a separate line. Because the result might be huge, print it modulo 999ドル\;999\;001$.

제한

서브태스크

번호배점제한
18

$B = 10,ドル $n \le 5,ドル $t = 1,ドル all digits except 0ドル$ are allowed

29

$B \le 10,ドル $B^n \le 10^5,ドル $t = 1$

39

$B \le 10,ドル $B^n \le 10^5$

432

$B \le 10,ドル $n \le 50$

513

$B \le 6,ドル $n \le 10^9$

614

$B \le 8,ドル $n \le 10^9$

715

$B \le 10,ドル $n \le 10^9$

예제 입력 1

10 3
2
0111111111
0010101010

예제 출력 1

56
17

힌트

Total number of 3-digit digidivisible numbers in base 10 is 56ドル$. If we only allow even digits, then there are 17 numbers left: 222, 224, 244, 248, 264, 288, 424, 444, 448, 488, 624, 648, 666, 824, 848, 864, 888.

출처

Contest > Innopolis Open in Informatics > Innopolis Open 2020-2021, Qualification, Contest 2 D번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /