結果

問題 No.16 累乗の加算
ユーザー notetonousnotetonous
提出日時 2016-04-11 00:13:38
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 21,120 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 23:55:09
合計ジャッジ時間 701 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 0 ms
6,940 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 0 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]);
      |                   ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}
0