結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-03-03 01:25:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 686 bytes |
| コンパイル時間 | 660 ms |
| コンパイル使用メモリ | 67,752 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-26 04:51:17 |
| 合計ジャッジ時間 | 1,490 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <iostream>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <set>
#include <vector>
using namespace std;
const int MOD = 1000003;
int main(int argc, char *argv[]) {
string s;
getline(cin, s);
int x, N;
{
stringstream ss(s);
ss >> x >> N;
}
vector<long long> a(N), b(N, 1);
getline(cin, s);
{
stringstream ss(s);
for (int i = 0; i < N; ++i) {
ss >> a[i];
}
}
long long p = 1, q = x;
for (int i = 1; i <= 30; ++i) {
for (int j = 0; j < N; ++j) {
if (a[j] & p) {
b[j] = (b[j] * q) % MOD;
}
}
p *= 2;
q = (q * q) % MOD;
}
long long ans = accumulate(b.begin(), b.end(), 0LL) % MOD;
cout << ans << endl;
return 0;
}
hotpepsi