結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-19 12:42:07 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 708 bytes |
| 記録 | |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 87,024 KB |
| 実行使用メモリ | 16,256 KB |
| 最終ジャッジ日時 | 2026-07-05 11:57:32 |
| 合計ジャッジ時間 | 1,806 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#pragma GCC target("sse4,avx,tune=native")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <cstdint>
#define MOD 1'000'003
using namespace std;
constexpr unsigned int pow_mod(const unsigned long long a, const unsigned long long b, const unsigned int mod)
{
return (b == 0 ? (mod == 1 ? 0 : 1) : (b & 1 ? a % mod : 1) * pow_mod((a % mod) * (a % mod) % mod, b >> 1, mod) % mod);
}
int main()
{
cin.tie(nullptr);
ios::sync_with_stdio(false);
uint16_t x, N, i;
uint32_t a[100], ans = 0;
cin >> x >> N;
for (i = 0; i != N; ++i) cin >> a[i];
for (i = 0; i != N; ++i)
ans = (ans + pow_mod(x, a[i], MOD)) % MOD;
cout << ans << '\n';
return 0;
}