結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2017-01-21 19:12:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 457 bytes |
コンパイル時間 | 528 ms |
コンパイル使用メモリ | 64,384 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:19:27 |
合計ジャッジ時間 | 1,174 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <iostream>using namespace std;using ll = long long;ll mod_pow(ll x, ll n, ll mod){if (n == 0) return 1;ll res = mod_pow(x * x % mod, n / 2, mod);if (n & 1) res = res * x % mod;return res;}int main(){ll x, N, res = 0;cin >> x >> N;for (int i = 0; i < N; i++) {ll a;cin >> a;res += mod_pow(x, a, 1000003);res %= 1000003;}cout << res << endl;return 0;}