結果

問題 No.2017 Mod7 Parade
ユーザー buey_tbuey_t
提出日時 2023-03-16 13:11:47
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,625 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 81,636 KB
実行使用メモリ 183,272 KB
最終ジャッジ日時 2023-10-18 12:59:27
合計ジャッジ時間 8,479 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
84,132 KB
testcase_01 AC 132 ms
84,128 KB
testcase_02 AC 128 ms
84,132 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 636 ms
183,220 KB
testcase_19 AC 628 ms
183,272 KB
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    try:
        import pypyjit
        pypyjit.set_param('max_unroll_recursion=-1')
    except:
        pass
    try:
        import sys
        sys.setrecursionlimit(10**7)
    except:
        pass
    from math import sqrt,sin,cos,tan,ceil,radians,floor,gcd,exp,log,log10,log2,factorial,fsum
    from heapq import heapify, heappop, heappush
    from bisect import bisect_left, bisect_right
    from copy import deepcopy
    import copy
    import random
    from collections import deque,Counter,defaultdict
    from itertools import permutations,combinations
    from decimal import Decimal,ROUND_HALF_UP
    #tmp = Decimal(mid).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
    from functools import lru_cache, reduce
    #@lru_cache(maxsize=None)
    from operator import add,sub,mul,xor,and_,or_,itemgetter
    INF = 10**18
    mod1 = 10**9+7
    mod2 = 998244353
    
    #DecimalならPython
    
    
    '''
    範囲を十進数にするのね
    あー、10で割っても余りには影響されないので
    個別で余り求めてしまってよい
    あとは主客転倒かな?
    総和だから厳しいな
    前から足していって、前から引いていけばいい
    無理か
    そもそもあまりに影響あるのか.....
    まあ割り算してるんだもんな
    だめだわ
    
    まあremに関してはD*Li + 10*いやわからn
    なんかdpで行けそうな雰囲気はあるな
    
    Lがかけられる10の数だろ
    あーーーーーえぐ
    部分列か
    順列じゃない
    
    10^nはmod7で循環する
    10^6 = 1 (mod7)だから、x = x*10^6 (mod7)
    
    部分列で、上の桁から順だから下からやっていかないといけない
    '''
    
    K = int(input())
    D = []
    L = []
    for i in range(K):
        d,l = map(int, input().split())
        D.append(d)
        L.append(l)
    
    dp = [[[0]*(7) for _ in range(6)] for _ in range(K+1)]
    dp[K][0][0] = 1
    
    for i in reversed(range(K)):
        for j in range(6):
            ad = int(str(D[i])*(L[i]%6) + '0'*j)%7
            for k in range(7):
                dp[i][(j+L[i])%6][(k+ad)%7] = dp[i+1][(j+L[i])%6][(k+ad)%7] + dp[i+1][j][k]
                dp[i][j][k] %= mod1
    
    ans = 0
    for i in range(6):
        for j in range(7):
            ans += dp[0][i][j]*j
            ans %= mod1
    
    print(ans)
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
if __name__ == '__main__':
    main()
0