結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
horiesiniti
|
| 提出日時 | 2016-07-17 17:32:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 365 bytes |
| コンパイル時間 | 404 ms |
| コンパイル使用メモリ | 22,912 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:15:20 |
| 合計ジャッジ時間 | 857 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%lld %d",&x,&n);
| ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d",&a);
| ~~~~~^~~~~~~~~
ソースコード
#include<stdio.h>
const int MOD=1000003;
long long int f(long long int x,int a){
long long int res=1;
while(a>0){
if((a%2)==1){
res=(res*x)%MOD;
}
x=(x*x)%MOD;
a/=2;
}
return res%MOD;
}
int main(){
long long int x,ans=0;
int n,a;
scanf("%lld %d",&x,&n);
for(int i=0;i<n;i++){
scanf("%d",&a);
ans=(ans+f(x,a))%MOD;
}
printf("%lld\n",ans);
}
horiesiniti