結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー ronpooronpoo
提出日時 2023-09-28 12:57:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 281 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 71,424 KB
最終ジャッジ日時 2023-09-28 12:57:51
合計ジャッジ時間 3,083 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,212 KB
testcase_01 AC 73 ms
70,960 KB
testcase_02 AC 73 ms
71,040 KB
testcase_03 AC 72 ms
71,376 KB
testcase_04 AC 73 ms
71,112 KB
testcase_05 AC 72 ms
71,128 KB
testcase_06 AC 73 ms
71,332 KB
testcase_07 AC 73 ms
71,172 KB
testcase_08 AC 73 ms
71,216 KB
testcase_09 AC 74 ms
71,268 KB
testcase_10 AC 74 ms
71,372 KB
testcase_11 AC 74 ms
71,328 KB
testcase_12 AC 72 ms
71,192 KB
testcase_13 AC 72 ms
71,372 KB
testcase_14 AC 72 ms
71,036 KB
testcase_15 AC 74 ms
71,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

M = int(input())

def power(a, b):
    d = len(format(b, 'b'))
    ret = 1
    n = a
    for i in range(d):
        if b & (1 << i) > 0:
            ret *= n
            ret %= M
        n = (n**2) % M
    return ret


v = power(2017*2017 % M, 2017)
ans = (2017 + v) % M
print(ans)
0