結果

問題 No.2703 FizzBuzz Letter Counting
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-01-27 17:23:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,526 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 88,960 KB
最終ジャッジ日時 2024-03-29 20:31:22
合計ジャッジ時間 81,531 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 37 ms
53,460 KB
testcase_02 AC 44 ms
59,860 KB
testcase_03 WA -
testcase_04 AC 409 ms
77,680 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2,111 ms
85,708 KB
testcase_10 WA -
testcase_11 AC 201 ms
76,912 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1,722 ms
83,664 KB
testcase_21 WA -
testcase_22 AC 607 ms
78,604 KB
testcase_23 AC 2,648 ms
88,540 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 63 ms
73,496 KB
testcase_44 AC 37 ms
53,460 KB
testcase_45 AC 37 ms
53,460 KB
testcase_46 AC 55 ms
68,120 KB
testcase_47 AC 37 ms
53,460 KB
testcase_48 AC 37 ms
53,460 KB
testcase_49 AC 46 ms
61,964 KB
testcase_50 AC 47 ms
64,024 KB
testcase_51 AC 54 ms
68,120 KB
testcase_52 AC 38 ms
53,460 KB
testcase_53 AC 37 ms
53,460 KB
testcase_54 AC 36 ms
53,460 KB
testcase_55 AC 37 ms
53,460 KB
testcase_56 AC 47 ms
64,024 KB
testcase_57 AC 70 ms
75,160 KB
testcase_58 AC 36 ms
53,460 KB
testcase_59 AC 36 ms
53,460 KB
testcase_60 AC 37 ms
53,460 KB
testcase_61 AC 36 ms
53,460 KB
testcase_62 AC 37 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD=998244353
def matrix_mul(a,b,MOD=None):
    ret=[[0]*len(b[0]) for i in range(len(a))]
    for i in range(len(a)):
        for j in range(len(b[0])):
            for k in range(len(b)):
                ret[i][j]+=a[i][k]*b[k][j]
            if MOD:
                ret[i][j]%=MOD
    return ret

def matrix_pow(x,p,MOD=None):
    if p==0:
        for i in range(len(x)):
            for j in range(len(x)):
                if i==j:
                    x[i][j]=1
                else:
                    x[i][j]=0
        return x
    if p==1:
        return x
    if p%2==1:
        return matrix_mul(matrix_pow(x,p-1,MOD),x,MOD)
    half=matrix_pow(x,p//2,MOD)
    return matrix_mul(half,half,MOD)

def rep(x):
    if x==1:
        return 1
    if x%2==1:
        return (rep(x-1)*10+1)%MOD
    else:
        half=rep(x//2)
        return (half*pow(10,x//2,MOD)+half)%MOD

M=int(input())
num=[tuple(map(int,input().split())) for i in range(M)]
S=0
N=0
for v,l in num:
    S+=l
    N*=pow(10,l,MOD*15)
    N+=rep(l)*v
    N%=MOD*15
if S<=6:
    ans=0
    for i in range(1,N+1):
        if i%15==0:
            ans+=8
        elif i%5==0:
            ans+=4
        elif i%3==0:
            ans+=4
        else:
            ans+=len(str(i))
    print(ans)
    exit()
bet=matrix_pow([[10,10,0],[0,10,0],[1,4,1]],S-2,MOD)[-1]
bet[0]*=96
bet[1]*=48
bet[2]*=0
fb=[8,S,S,4,S,4,4,S,S,4,4,S,4,S,S]
sz=(N+1-pow(10,S-1,MOD*15))%(MOD*15)
ans=sum(bet)+(8*S+32)*(sz//15)+21
for i in range(sz%15):
    ans+=fb[(i+10)%15]
print(ans%MOD)
0