結果

問題 No.16 累乗の加算
ユーザー notetonousnotetonous
提出日時 2016-04-11 00:19:34
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 1,019 ms
コンパイル使用メモリ 24,412 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 11:57:20
合計ジャッジ時間 974 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,376 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 0 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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);
    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