結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
notetonous
|
| 提出日時 | 2016-04-11 00:19:34 |
| 言語 | C90(gcc12) (gcc 12.4.0) |
| 結果 |
AC
|
| 実行時間 | 0 ms / 5,000 ms |
| + 686µs | |
| コード長 | 443 bytes |
| 記録 | |
| コンパイル時間 | 47 ms |
| コンパイル使用メモリ | 29,696 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-24 08:59:30 |
| 合計ジャッジ時間 | 1,242 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:17:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
17 | scanf("%d %d",&x,&N);
| ^~~~~~~~~~~~~~~~~~~~
main.c:18:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | for(i=0;i<N;i++)scanf("%d",&a[i]);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#define mod 1000003
int x,N;
int a[100];
long long int ans;
long long int power(int x,int n){
long long int res=0;
if(n==0)return 1;
else if(n%2==0){
res=power(x,n/2);
return res*res%mod;
}
else return power(x,n-1)*x%mod;
}
int main(){
int i;
scanf("%d %d",&x,&N);
for(i=0;i<N;i++)scanf("%d",&a[i]);
for(i=0;i<N;i++){
ans=(ans+power(x,a[i]))%mod;
}
printf("%lld\n",ans);
return 0;
}
notetonous