結果

問題 No.1407 Kindness
ユーザー titiatitia
提出日時 2021-02-26 22:36:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 803 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 26,624 KB
最終ジャッジ日時 2024-04-10 13:15:28
合計ジャッジ時間 8,966 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,880 KB
testcase_01 AC 562 ms
26,496 KB
testcase_02 AC 542 ms
26,496 KB
testcase_03 AC 545 ms
26,624 KB
testcase_04 AC 548 ms
26,496 KB
testcase_05 AC 546 ms
26,496 KB
testcase_06 AC 549 ms
26,496 KB
testcase_07 AC 542 ms
26,496 KB
testcase_08 AC 530 ms
26,496 KB
testcase_09 AC 539 ms
26,496 KB
testcase_10 AC 552 ms
26,496 KB
testcase_11 AC 551 ms
26,624 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 AC 550 ms
26,496 KB
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 556 ms
26,496 KB
testcase_37 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=input().strip()
mod=10**9+7


if int(N)<=2000:
    
    ANS=0
    for i in range(int(N)+1):
        x=str(i)
        SX=1
        for y in x:
            SX=SX*int(y)
        ANS+=SX
    print(ANS%mod)
    exit()

S=[1,45]
for i in range(2*10**5):
    S.append(S[-1]*45%mod)

S1=[0,45]
for i in range(2*10**5):
    S1.append((S1[-1]+pow(45,i+2,mod))%mod)


H=[0,1,3,6,10,15,21,28,36,45,0]
H1=[1,2,4,7,11,16,22,29,37,46]

ANS=0
kakeru=1
LEN=len(N)

for i in range(LEN):
    if i==0:
        ANS=ANS+(H[int(N[i])-1])*pow(45,LEN-i-1,mod)+S1[LEN-i-1]
    elif i==LEN-1:
        ANS=ANS+kakeru*H[int(N[i])]*S[LEN-i-1]      
    else:
        ANS=ANS+kakeru*H[int(N[i])-1]*S[LEN-i-1]
        
    ANS%=mod

    kakeru=kakeru*int(N[i])%mod

    #print(ANS)

print(ANS)
0