結果

問題 No.1161 Many Powers
ユーザー Sooh31Sooh31
提出日時 2020-08-18 22:25:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 591 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 194,392 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 07:57:56
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 26 ms
6,944 KB
testcase_09 AC 31 ms
6,944 KB
testcase_10 AC 12 ms
6,940 KB
testcase_11 AC 22 ms
6,940 KB
testcase_12 AC 12 ms
6,944 KB
testcase_13 AC 35 ms
6,944 KB
testcase_14 AC 55 ms
6,944 KB
testcase_15 AC 46 ms
6,940 KB
testcase_16 AC 60 ms
6,940 KB
testcase_17 AC 40 ms
6,940 KB
testcase_18 AC 29 ms
6,940 KB
testcase_19 AC 18 ms
6,940 KB
testcase_20 AC 63 ms
6,940 KB
testcase_21 AC 17 ms
6,940 KB
testcase_22 AC 64 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const ll mod = 1000000007;
const int INF = 1001001001;

ll modpow(ll a, ll p, ll mod){
    ll res = 1;
    while(p){
        if(p & 1) res = res * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return res;
}

int main(){
    ll a, b; cin >> a >> b;
    ll c; cin >> c;
    ll cnt = a / c;
    ll res = a % c;
    ll ans = 0;
    for(int i = 1; i <= c; i++){
        if(i <= res) ans += modpow(i, b, c) * (cnt + 1);
        else ans += modpow(i, b, c) * cnt;
        ans %= c;
    }
    cout << ans << endl;
}
0