結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-11-02 11:38:26 |
| 言語 | C(gnu17) (gcc 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 5,000 ms |
| コード長 | 676 bytes |
| 記録 | |
| コンパイル時間 | 1,054 ms |
| コンパイル使用メモリ | 38,228 KB |
| 最終ジャッジ日時 | 2026-02-23 22:47:06 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
#include <stdio.h>
int main(void) {
long long int x, n;
long long int a[101];
long long int i, j;
long long int total = 0;
long long int subtotal, an;
scanf("%lld%lld", &x, &n);
for(i = 1;i <= n;i++){
scanf("%lld", &a[i]);
}
for(i = 1;i <= n;i++){
subtotal= 1;
an = x;
while(a[i] != 0){
//printf("a[%lld] = %lld %lld\n", i, a[i], an);
if(a[i] % 2 == 1){
subtotal = (subtotal * an) % 1000003;
}
//for(j = 0;j < a[i];j++){
an = (an * an) % 1000003;
a[i] /= 2;
}
//printf("subtotal = %lld\n", subtotal);
total = (total + subtotal) % 1000003;
}
//printf("total = %lld\n", total % 1000003);
printf("%lld\n", total);
return 0;
}
suppy193