結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2016-04-11 00:19:34 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 443 bytes |
コンパイル時間 | 1,537 ms |
コンパイル使用メモリ | 20,736 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 05:12:32 |
合計ジャッジ時間 | 766 ms |
ジャッジサーバーID (参考情報) |
judge5 / 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 1000003int 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;}