結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2016-04-11 00:13:38 |
言語 | C90 (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 445 bytes |
コンパイル時間 | 194 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-04 05:55:40 |
合計ジャッジ時間 | 1,119 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 WA * 10 |
コンパイルメッセージ
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)%mod; 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; }