結果

問題 No.1161 Many Powers
ユーザー MZKiMZKi
提出日時 2020-08-17 00:26:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 971 bytes
コンパイル時間 1,062 ms
コンパイル使用メモリ 158,012 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-19 18:37:08
合計ジャッジ時間 2,553 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 5 ms
6,940 KB
testcase_06 AC 6 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 43 ms
6,944 KB
testcase_09 AC 51 ms
6,944 KB
testcase_10 AC 19 ms
6,944 KB
testcase_11 AC 36 ms
6,944 KB
testcase_12 AC 19 ms
6,940 KB
testcase_13 AC 56 ms
6,940 KB
testcase_14 AC 95 ms
6,940 KB
testcase_15 AC 73 ms
6,944 KB
testcase_16 AC 82 ms
6,944 KB
testcase_17 AC 61 ms
6,940 KB
testcase_18 AC 50 ms
6,944 KB
testcase_19 AC 30 ms
6,944 KB
testcase_20 AC 110 ms
6,944 KB
testcase_21 AC 21 ms
6,940 KB
testcase_22 AC 65 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<ll,pair<ll,ll>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

ll modpow(ll a, ll n, ll modo) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % modo;
        a = a * a % modo;
        n >>= 1;
    }
    return res;
}

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