結果

問題 No.16 累乗の加算
ユーザー treeonetreeone
提出日時 2016-07-11 12:51:55
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 641 bytes
コンパイル時間 3,442 ms
コンパイル使用メモリ 145,128 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 12:00:10
合計ジャッジ時間 2,082 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

int x, n;
const int mod = 1000003;

int mod_pow(int x, int a){
    if(a == 0) return 1;
    if(a % 2) return x * mod_pow(x, a - 1) % mod;
    int res = mod_pow(x, a / 2);
    return res * res % mod;
}

signed main(){
    cin >> x >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    rep(i, 0, n){
        ans += mod_pow(x, a[i]);
        ans %= mod;
    }
    cout << ans << endl;
}
0