結果

問題 No.1086 桁和の桁和2
ユーザー tyawanmusityawanmusi
提出日時 2020-01-20 19:39:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,036 ms / 3,000 ms
コード長 896 bytes
コンパイル時間 132 ms
コンパイル使用メモリ 10,880 KB
実行使用メモリ 26,552 KB
最終ジャッジ日時 2023-09-29 23:42:04
合計ジャッジ時間 39,543 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,732 KB
testcase_01 AC 15 ms
7,796 KB
testcase_02 AC 16 ms
7,752 KB
testcase_03 AC 16 ms
7,740 KB
testcase_04 AC 16 ms
7,908 KB
testcase_05 AC 1,843 ms
26,540 KB
testcase_06 AC 15 ms
7,816 KB
testcase_07 AC 16 ms
7,904 KB
testcase_08 AC 15 ms
7,848 KB
testcase_09 AC 15 ms
7,824 KB
testcase_10 AC 1,139 ms
18,496 KB
testcase_11 AC 313 ms
10,964 KB
testcase_12 AC 72 ms
8,732 KB
testcase_13 AC 1,439 ms
21,932 KB
testcase_14 AC 909 ms
16,268 KB
testcase_15 AC 257 ms
10,756 KB
testcase_16 AC 1,414 ms
20,292 KB
testcase_17 AC 132 ms
9,304 KB
testcase_18 AC 1,964 ms
24,388 KB
testcase_19 AC 1,614 ms
22,180 KB
testcase_20 AC 213 ms
9,688 KB
testcase_21 AC 1,387 ms
19,696 KB
testcase_22 AC 1,958 ms
24,216 KB
testcase_23 AC 1,202 ms
18,220 KB
testcase_24 AC 846 ms
15,692 KB
testcase_25 AC 1,657 ms
21,828 KB
testcase_26 AC 1,369 ms
19,268 KB
testcase_27 AC 988 ms
16,644 KB
testcase_28 AC 817 ms
15,084 KB
testcase_29 AC 925 ms
16,192 KB
testcase_30 AC 2,028 ms
26,396 KB
testcase_31 AC 2,028 ms
26,552 KB
testcase_32 AC 2,036 ms
25,484 KB
testcase_33 AC 2,031 ms
25,688 KB
testcase_34 AC 2,034 ms
25,616 KB
testcase_35 AC 1,854 ms
25,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9 + 7
n = int(input())
l = list(map(int, input().split()))
r = list(map(int, input().split()))
d = list(map(int, input().split()))

def calc(l, r, di, dj):
  #(10^l <= a < 10^r or a=0) and f(di+f(a))=djを満たすaの数
  if dj == 0:
    if di == 0:
      #di==dj==0のとき、a=0の1通りのみ
      return 1
    else:
      #di!=dj==0のとき、条件を満たすaは存在しない
      return 0
  else:
    #aの総数は(10^r - 10^l)/9で一般化される
    #di==djの時、a=0の1通りが加算される
    ans_r = pow(10, r, mod) * pow(9, mod - 2, mod)#逆元です
    ans_l = pow(10, l, mod) * pow(9, mod - 2, mod)
    ans=(ans_r + (mod - ans_l)) % mod
    if di == dj:
      ans += 1
      ans %= mod#これ必要ですか?
    return ans

ans = calc(l[0], r[0], 0, d[0])
for i in range(1, n):
    ans *= calc(l[i], r[i], d[i - 1], d[i])
    ans %= mod

print(ans)
0