結果

問題 No.487 2017 Calculation(2017の計算)
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-03 00:30:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 87,276 KB
実行使用メモリ 71,656 KB
最終ジャッジ日時 2023-09-27 07:08:19
合計ジャッジ時間 2,439 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,336 KB
testcase_01 AC 65 ms
71,656 KB
testcase_02 AC 65 ms
71,476 KB
testcase_03 AC 67 ms
71,332 KB
testcase_04 AC 63 ms
71,376 KB
testcase_05 AC 66 ms
71,336 KB
testcase_06 AC 63 ms
71,192 KB
testcase_07 AC 62 ms
71,540 KB
testcase_08 AC 63 ms
71,412 KB
testcase_09 AC 64 ms
71,336 KB
testcase_10 AC 65 ms
71,188 KB
testcase_11 AC 63 ms
71,324 KB
testcase_12 AC 62 ms
71,340 KB
testcase_13 AC 63 ms
71,484 KB
testcase_14 AC 64 ms
71,572 KB
testcase_15 AC 63 ms
71,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = int(input())

def power(a, n, mod):
    bi=str(format(n,"b")) #2進数
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

ans = 0
ans += 2017%mod
temp = 2017*2017
temp %= mod
ans += power(temp, 2017, mod)
ans %= mod
print(ans)
0