結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
notetonous
|
| 提出日時 | 2016-04-11 00:19:34 |
| 言語 | C90(gcc12) (gcc 12.4.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 443 bytes |
| 記録 | |
| コンパイル時間 | 163 ms |
| コンパイル使用メモリ | 30,152 KB |
| 最終ジャッジ日時 | 2026-02-23 21:07:14 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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