結果

問題 No.1161 Many Powers
ユーザー 👑 rin204rin204
提出日時 2020-08-13 06:01:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 509 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-04-18 01:11:37
合計ジャッジ時間 5,702 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 31 ms
10,752 KB
testcase_03 AC 33 ms
10,624 KB
testcase_04 AC 31 ms
10,752 KB
testcase_05 AC 48 ms
11,008 KB
testcase_06 AC 47 ms
10,880 KB
testcase_07 AC 32 ms
10,624 KB
testcase_08 AC 223 ms
12,928 KB
testcase_09 AC 227 ms
12,800 KB
testcase_10 AC 101 ms
11,392 KB
testcase_11 AC 158 ms
12,160 KB
testcase_12 AC 90 ms
11,520 KB
testcase_13 AC 285 ms
12,800 KB
testcase_14 AC 449 ms
14,592 KB
testcase_15 AC 387 ms
13,568 KB
testcase_16 AC 497 ms
14,464 KB
testcase_17 AC 328 ms
13,440 KB
testcase_18 AC 214 ms
12,544 KB
testcase_19 AC 124 ms
11,904 KB
testcase_20 AC 509 ms
15,104 KB
testcase_21 AC 133 ms
11,648 KB
testcase_22 AC 498 ms
14,848 KB
testcase_23 AC 31 ms
10,752 KB
testcase_24 AC 31 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

a, b, c = map(int, input().split())
ans = 0
if a <= c:
    for i in range(1, a + 1):
        ans += pow(i, b, c)
        ans %= c
else:
    lst = []
    for i in range(1, c + 1):
        lst.append(pow(i, b, c))
    total = sum(lst)
    ans += a // c * total
    pos = a % c
    ans += sum(lst[:pos])
    ans %= c
print(ans)
0