結果

問題 No.2017 Mod7 Parade
ユーザー siganaisiganai
提出日時 2022-07-22 21:56:08
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 290 ms / 2,000 ms
コード長 701 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 94,548 KB
最終ジャッジ日時 2023-09-17 09:51:39
合計ジャッジ時間 6,257 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
78,980 KB
testcase_01 AC 140 ms
79,076 KB
testcase_02 AC 139 ms
78,876 KB
testcase_03 AC 255 ms
91,528 KB
testcase_04 AC 221 ms
87,988 KB
testcase_05 AC 205 ms
86,016 KB
testcase_06 AC 268 ms
92,640 KB
testcase_07 AC 163 ms
80,424 KB
testcase_08 AC 218 ms
87,384 KB
testcase_09 AC 175 ms
80,808 KB
testcase_10 AC 220 ms
87,632 KB
testcase_11 AC 246 ms
90,200 KB
testcase_12 AC 234 ms
88,928 KB
testcase_13 AC 290 ms
94,300 KB
testcase_14 AC 287 ms
94,160 KB
testcase_15 AC 286 ms
94,352 KB
testcase_16 AC 289 ms
94,408 KB
testcase_17 AC 283 ms
94,432 KB
testcase_18 AC 275 ms
94,548 KB
testcase_19 AC 210 ms
94,188 KB
testcase_20 AC 142 ms
79,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=10 ** 9 + 7

import sys
input=sys.stdin.readline

k = int(input())
li = [0,1,4,6,5,2]
dp = [[0] * 7 for _ in range(k+1)]
ans = 0
for i in range(k):
    d,l = map(int,input().split())
    p10 = pow(10,l,7)
    xx = li[l % 6] * d % 7
    dp[i+1][xx] += 1
    for j in range(7):
        dp[i+1][(j * p10 + xx) % 7] += dp[i][j]
        dp[i+1][(j * p10 + xx) % 7] %= mod
    for j in range(7):
        ans += dp[i+1][j] * j % mod
        ans %= mod
        dp[i+1][j] += dp[i][j]

print(ans)
0