結果

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

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.readline
    a = int(input())
    b = list(map(int, list(input())[:-1]))
    ans = 0
    mod = 10 ** 9 + 7
    for i in range(1, len(b)):
        if i != len(b) - 1:
            ans += i * pow(a, i, mod) * (a - 1)
            ans %= mod
        else:
            ans += i * (b[-(i + 1)] - 1) * pow(a, i, mod)
            ans %= mod
    ########関数部分##############
    def Base_n_to_10(X,n):
        out = 0
        for i in range(1,len(str(X))+1):
            out += int(X[-i])*pow(n,(i-1),mod)
            out %= mod
        return out#int out
    ############################
    print((ans + (len(b) - 1) * (Base_n_to_10("".join(list(map(str, b[1:]))), a) + 1)) % mod)
if __name__ == '__main__':
    main()
    
0