結果

問題 No.16 累乗の加算
ユーザー fiord
提出日時 2015-05-25 23:37:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 350 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 54,236 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-26 04:53:31
合計ジャッジ時間 987 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long int ll;
#define E 1000003

ll fac(ll a,ll b){//a^bを計算
	ll ans=1;
	while(b){
		if(b&1)	ans=(ans*a)%E;
		a=(a*a)%E;
		b>>=1;
	}
	return ans;
}

int main(){
	int x,n;	cin>>x>>n;
	ll ans=0;
	int a;
	for(int i=0;i<n;i++){
		cin>>a;
		ans=(ans+fac(x,a))%E;
	}
	cout<<ans<<endl;
	return 0;
}
0