結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
hiyokko2
|
| 提出日時 | 2017-08-05 15:35:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 634 bytes |
| コンパイル時間 | 1,374 ms |
| コンパイル使用メモリ | 157,920 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:23:54 |
| 合計ジャッジ時間 | 2,015 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;
ll mod_pow(ll x, ll n, ll mod)
{
ll res = 1;
while (n > 0) {
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
signed main()
{
int x, N;
int a;
const int mod = 1000003;
cin >> x >> N;
int ans = 0;
REP(i,N) {
cin >> a;
ans += mod_pow(x, a, mod);
}
cout << ans % mod << endl;
}
hiyokko2