結果

問題 No.2017 Mod7 Parade
ユーザー asumo0729asumo0729
提出日時 2022-07-22 21:58:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 370 ms / 2,000 ms
コード長 1,285 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,356 KB
実行使用メモリ 89,456 KB
最終ジャッジ日時 2023-09-17 09:56:20
合計ジャッジ時間 6,879 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
72,820 KB
testcase_01 AC 114 ms
72,364 KB
testcase_02 AC 112 ms
72,720 KB
testcase_03 AC 319 ms
87,028 KB
testcase_04 AC 258 ms
84,424 KB
testcase_05 AC 225 ms
83,052 KB
testcase_06 AC 335 ms
87,824 KB
testcase_07 AC 161 ms
79,940 KB
testcase_08 AC 251 ms
84,456 KB
testcase_09 AC 178 ms
80,952 KB
testcase_10 AC 249 ms
84,160 KB
testcase_11 AC 292 ms
86,008 KB
testcase_12 AC 275 ms
85,168 KB
testcase_13 AC 364 ms
89,336 KB
testcase_14 AC 365 ms
89,352 KB
testcase_15 AC 365 ms
89,456 KB
testcase_16 AC 364 ms
89,304 KB
testcase_17 AC 370 ms
89,348 KB
testcase_18 AC 355 ms
89,216 KB
testcase_19 AC 213 ms
89,200 KB
testcase_20 AC 111 ms
72,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from operator import itemgetter
from collections import defaultdict, deque
import heapq
from heapq import heapify, heappop, _heapify_max, heappush
from bisect import bisect_left, bisect_right
import math
import itertools
import copy

stdin=sys.stdin
#sys.setrecursionlimit(10 ** 7)
## import pypyjit
## pypyjit.set_param('max_unroll_recursion=-1')

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
Yp=lambda:print('Yes')
Np=lambda:print('No')
inf = 1 << 60
inf = float('inf')
mod = 10 ** 9 + 7
#mod = 998244353
eps = 1e-9
sortkey1 = itemgetter(0)
sortkey2 = lambda x: (x[0], x[1])



###############################################################

K = ip()
DL = [lp() for _ in range(K)]
dp = [0 for _ in range(7)]
dp[0] = 1
for (d, l) in DL:
    prev = dp
    dp = [0 for _ in range(7)]
    for i in range(7):
        dp[i] += prev[i]
        dp[i] %= mod

    ten = pow(10, l, 7)
    p, q = divmod(l, 6)
    if q:
        x = int(str(d) * q) % 7
    else:
        x = 0
    x = x * pow(10, 6 * p, 7)
    x %= 7
    for i in range(7):
        j = (i * ten + x) % 7
        dp[j] += prev[i]
        dp[j] %= mod

ans = 0
for i in range(7):
    ans += i * dp[i]
    ans %= mod
print(ans)
exit()
0