結果
問題 | No.16 累乗の加算 |
ユーザー |
|
提出日時 | 2024-10-30 20:14:27 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 2,283 ms |
コンパイル使用メモリ | 200,928 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-30 20:14:31 |
合計ジャッジ時間 | 3,351 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll = long long;#define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i)#define all(a) (a).begin(), (a).end()ll modpow(ll a, ll n, ll m) {ll res = 1;while (n > 0) {if (n & 1) res = res * a % m;a = a * a % m;n >>= 1;}return res;}const ll mod = 1000003;int main() {cin.tie(nullptr);ll x, N;cin >> x >> N;ll ans = 0;rep(i, 0, N) {ll a;cin >> a;ans += modpow(x, a, mod);ans %= mod;}cout << ans << '\n';}