結果

問題 No.1407 Kindness
ユーザー 👑 Kazun
提出日時 2021-07-05 04:10:03
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 335 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,200 KB
実行使用メモリ 77,672 KB
最終ジャッジ日時 2024-07-01 11:54:35
合計ジャッジ時間 3,610 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 RE * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache

@lru_cache(None)
def f(N):
    if N<=9:
        return N*(N+1)//2

    q,r=divmod(N,10)

    a=r*(r+1)//2
    b=(10+r)*(9-r)//2

    return ((1+f(q))*a+(1+f(q-1))*b)%Mod

N=int(input())
Mod=10**9+7

N_str=[int(n) for n in str(N)]
M=0

for n in N_str:
    M=10*M+n
    _=f(M);
    _=f(M-1);

print(f(N))
0