結果

問題 No.1086 桁和の桁和2
ユーザー tyawanmusityawanmusi
提出日時 2020-01-20 20:22:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 536 ms / 3,000 ms
コード長 907 bytes
コンパイル時間 371 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 109,832 KB
最終ジャッジ日時 2023-09-29 23:42:57
合計ジャッジ時間 13,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,408 KB
testcase_01 AC 63 ms
71,412 KB
testcase_02 AC 64 ms
71,440 KB
testcase_03 AC 59 ms
71,356 KB
testcase_04 AC 59 ms
71,228 KB
testcase_05 AC 490 ms
109,652 KB
testcase_06 AC 63 ms
71,056 KB
testcase_07 AC 61 ms
71,312 KB
testcase_08 AC 61 ms
71,288 KB
testcase_09 AC 61 ms
71,188 KB
testcase_10 AC 327 ms
93,216 KB
testcase_11 AC 142 ms
79,732 KB
testcase_12 AC 86 ms
76,508 KB
testcase_13 AC 399 ms
101,760 KB
testcase_14 AC 285 ms
90,708 KB
testcase_15 AC 127 ms
78,504 KB
testcase_16 AC 388 ms
95,344 KB
testcase_17 AC 100 ms
76,588 KB
testcase_18 AC 521 ms
109,140 KB
testcase_19 AC 428 ms
102,108 KB
testcase_20 AC 114 ms
77,448 KB
testcase_21 AC 383 ms
95,392 KB
testcase_22 AC 518 ms
109,764 KB
testcase_23 AC 344 ms
93,348 KB
testcase_24 AC 259 ms
88,512 KB
testcase_25 AC 440 ms
104,752 KB
testcase_26 AC 375 ms
95,004 KB
testcase_27 AC 294 ms
90,364 KB
testcase_28 AC 251 ms
87,072 KB
testcase_29 AC 276 ms
88,724 KB
testcase_30 AC 529 ms
109,000 KB
testcase_31 AC 536 ms
109,812 KB
testcase_32 AC 532 ms
109,832 KB
testcase_33 AC 528 ms
109,496 KB
testcase_34 AC 523 ms
109,360 KB
testcase_35 AC 492 ms
109,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#writer解
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