結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
Dadarithm
|
| 提出日時 | 2015-10-05 23:21:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 590 bytes |
| コンパイル時間 | 586 ms |
| コンパイル使用メモリ | 63,512 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:02:13 |
| 合計ジャッジ時間 | 1,230 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int main()
{
int x, N; vector<ll> a, memo;
cin >> x >> N;
a.resize(N);
for (auto &p : a)
cin >> p;
int key = 1;
memo.push_back(x);
for (int i = 0; key <= 100000000; ++i)
{
memo.push_back(memo[i] * memo[i] % 1000003);
key *= 2;
}
int ans = 0;
for (int i = 0; i < N; ++i)
{
ll pAns = 1;
for (int j = 0; j < memo.size(); ++j)
{
if (a[i] & 1 << j)
pAns = pAns * memo[j] % 1000003;
}
ans = (ans + pAns) % 1000003;
}
cout << ans << endl;
return 0;
}
Dadarithm