結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
カルロス
|
| 提出日時 | 2015-08-31 15:27:37 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 20,992 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:02:04 |
| 合計ジャッジ時間 | 1,079 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:15:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d %d", &x, &N);
| ^~~~~~~~~~~~~~~~~~~~~~
main.c:18:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%lld", &a);
| ^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
long long mpow(int mx, long long ma){
if(ma==1){return mx;}
if(ma==0){return 1;}
if(ma%2==1){
return mx * mpow(mx, ma-1) % 1000003;
}else{
return mpow(mx, ma/2) * mpow(mx, ma/2) % 1000003;
}
}
int main(void){
int i, x, N;
scanf("%d %d", &x, &N);
long long t = 0, a;
for(i=0;i<N;i++){
scanf("%lld", &a);
t += mpow(x, a);
}
printf("%lld\n", t%1000003);
return 0;
}
カルロス