結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
opqopq_
|
| 提出日時 | 2015-05-25 17:35:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 502 bytes |
| コンパイル時間 | 127 ms |
| コンパイル使用メモリ | 23,168 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 04:53:29 |
| 合計ジャッジ時間 | 737 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d%d", &x, &N);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:21:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | for (int i = 0; i < N; i++) scanf("%d", a+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
using namespace std;
#define MOD 1000003
#define N_MAX 100
int x, N;
int a[N_MAX];
long long PowMod(long long x, long long n, long long mod) {
long long ret = 1;
while (0 < n) {
if (n & 1) ret = ret * x % mod;
x = x * x % mod;
n >>= 1;
}
return ret;
}
int main() {
scanf("%d%d", &x, &N);
for (int i = 0; i < N; i++) scanf("%d", a+i);
int res = 0;
for (int i = 0; i < N; i++) {
res += PowMod(x, a[i], MOD);
res %= MOD;
}
printf("%d\n", res);
return 0;
}
opqopq_