結果

問題 No.1161 Many Powers
ユーザー LyricalMaestro
提出日時 2024-10-30 00:45:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 488 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 60,168 KB
最終ジャッジ日時 2024-10-30 00:45:47
合計ジャッジ時間 4,000 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/1161


def main():
    A, B, C = map(int, input().split())

    x = A // C
    ans = 0
    for c in range(1, C + 1):
        y = pow(c, B, C)        
        ans += y
        ans %= C
    
    ans *= x
    ans %= C

    for z in range(x * C + 1, A + 1):
        y = pow(z, B, C)
        ans += y
        ans %= C
    print(ans)



    



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