結果

問題 No.1407 Kindness
ユーザー 👑 KazunKazun
提出日時 2021-02-27 00:32:28
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 214 ms
コンパイル使用メモリ 82,516 KB
実行使用メモリ 85,632 KB
最終ジャッジ日時 2024-04-10 14:53:19
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
52,068 KB
testcase_01 AC 32 ms
53,764 KB
testcase_02 AC 31 ms
53,012 KB
testcase_03 AC 31 ms
52,640 KB
testcase_04 AC 31 ms
52,572 KB
testcase_05 AC 31 ms
52,008 KB
testcase_06 AC 31 ms
52,924 KB
testcase_07 AC 30 ms
53,040 KB
testcase_08 AC 32 ms
53,136 KB
testcase_09 AC 34 ms
53,072 KB
testcase_10 AC 35 ms
52,812 KB
testcase_11 AC 34 ms
53,612 KB
testcase_12 AC 68 ms
84,456 KB
testcase_13 AC 49 ms
70,740 KB
testcase_14 AC 50 ms
71,512 KB
testcase_15 AC 67 ms
83,736 KB
testcase_16 AC 52 ms
74,244 KB
testcase_17 AC 49 ms
72,456 KB
testcase_18 AC 54 ms
73,308 KB
testcase_19 AC 67 ms
83,032 KB
testcase_20 AC 64 ms
81,516 KB
testcase_21 AC 48 ms
66,892 KB
testcase_22 AC 49 ms
67,780 KB
testcase_23 AC 63 ms
81,480 KB
testcase_24 AC 73 ms
85,632 KB
testcase_25 AC 50 ms
72,268 KB
testcase_26 AC 53 ms
74,224 KB
testcase_27 AC 49 ms
67,120 KB
testcase_28 AC 67 ms
83,364 KB
testcase_29 AC 45 ms
64,768 KB
testcase_30 AC 70 ms
84,744 KB
testcase_31 AC 49 ms
68,704 KB
testcase_32 AC 59 ms
83,024 KB
testcase_33 AC 45 ms
68,308 KB
testcase_34 AC 47 ms
73,624 KB
testcase_35 AC 44 ms
67,036 KB
testcase_36 AC 44 ms
64,480 KB
testcase_37 AC 65 ms
85,444 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(s,t):
    if s<=t:
        return (s+t)*(t-s+1)//2
    else:
        return 0

N=input()

Mod=10**9+7

DP=[[0,0] for _ in range(len(N))]
X=[x*(x+1)//2 for x in range(10)]

n=int(N[0])
DP[0][0]=n*(n+1)//2
DP[0][1]=n*(n-1)//2

for i,r in enumerate(N[1:],1):
    D=DP[i]
    E=DP[i-1]
    r=int(r)

    D[0]=((E[0]+1)*f(0,r)  +(E[1]+1)*f(r+1,9))%Mod
    D[1]=((E[0]+1)*f(0,r-1)+(E[1]+1)*f(r  ,9))%Mod
print(DP[-1][0])
0