結果

問題 No.1580 I like Logarithm!
ユーザー tamatotamato
提出日時 2021-07-02 21:48:35
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 516 bytes
コンパイル時間 1,226 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 82,824 KB
最終ジャッジ日時 2023-09-11 21:39:30
合計ジャッジ時間 7,135 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,428 KB
testcase_01 AC 68 ms
71,460 KB
testcase_02 AC 67 ms
71,292 KB
testcase_03 AC 68 ms
71,632 KB
testcase_04 AC 70 ms
71,680 KB
testcase_05 AC 69 ms
71,360 KB
testcase_06 AC 107 ms
78,512 KB
testcase_07 AC 154 ms
82,372 KB
testcase_08 AC 74 ms
71,408 KB
testcase_09 AC 77 ms
76,432 KB
testcase_10 AC 85 ms
76,376 KB
testcase_11 AC 126 ms
79,660 KB
testcase_12 AC 131 ms
80,428 KB
testcase_13 AC 119 ms
79,352 KB
testcase_14 AC 155 ms
82,520 KB
testcase_15 AC 136 ms
81,068 KB
testcase_16 AC 69 ms
71,464 KB
testcase_17 AC 70 ms
71,460 KB
testcase_18 AC 73 ms
71,360 KB
testcase_19 AC 67 ms
71,284 KB
testcase_20 AC 68 ms
71,432 KB
testcase_21 AC 70 ms
71,420 KB
testcase_22 AC 69 ms
71,472 KB
testcase_23 AC 68 ms
71,284 KB
testcase_24 AC 69 ms
71,360 KB
testcase_25 AC 68 ms
71,396 KB
testcase_26 AC 156 ms
82,596 KB
testcase_27 AC 158 ms
82,620 KB
testcase_28 AC 158 ms
82,712 KB
testcase_29 AC 160 ms
82,620 KB
testcase_30 AC 155 ms
82,560 KB
testcase_31 AC 159 ms
82,524 KB
testcase_32 AC 159 ms
82,824 KB
testcase_33 AC 160 ms
82,536 KB
testcase_34 AC 157 ms
82,528 KB
testcase_35 AC 159 ms
82,716 KB
testcase_36 AC 158 ms
82,640 KB
testcase_37 AC 154 ms
82,596 KB
testcase_38 AC 163 ms
82,564 KB
testcase_39 AC 158 ms
82,776 KB
testcase_40 AC 159 ms
82,568 KB
testcase_41 AC 161 ms
82,400 KB
testcase_42 AC 159 ms
82,620 KB
testcase_43 AC 157 ms
82,736 KB
testcase_44 AC 158 ms
82,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    a = int(input())
    B = input().rstrip('\n')
    B = list(map(int, B))

    bb = 0
    for i in range(len(B)):
        bb = (bb + B[-i-1] * (pow(a, i, mod))%mod)%mod
    ans = 0
    for i in range(len(B)):
        if i == len(B) - 1:
            ans = (ans + i * (bb - pow(a, i, mod) + 1))%mod
        else:
            ans = (ans + i * (a-1) * pow(a, i, mod))%mod
    print(ans)


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