結果

問題 No.1580 I like Logarithm!
ユーザー ygd.ygd.
提出日時 2021-07-02 21:58:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 65,152 KB
最終ジャッジ日時 2024-06-29 11:30:40
合計ジャッジ時間 3,679 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    A = int(input()); MOD = pow(10,9) + 7
    B = list(str(input()))
    B = [int(b) for b in B]
    B.reverse()
    N = len(B)
    ans = 0
    powa = 1
    cum = 0
    for i in range(N):
        if i != N-1:
            temp = i*powa*(A-1)%MOD
            cum += powa*B[i]%MOD
            cum %= MOD
        else:
            cum += powa*B[i]%MOD
            temp = i*(cum - powa + 1)%MOD
        #print(i,cum,temp)
        ans += temp
        ans %= MOD
        powa = powa*A%MOD
    print(ans)

if __name__ == '__main__':
    main()
0