結果

問題 No.251 大きな桁の復習問題(1)
ユーザー fiordfiord
提出日時 2015-07-24 23:59:14
言語 C++11
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 571 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 158,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-16 01:03:00
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define E 129402307
int main(){
	srand((unsigned)time(NULL));
	string n,m;	cin>>n>>m;
	ll nextn=0;
	for(int i=0;i<(int)n.size();i++){
		nextn=nextn*10+(ll)(n[i]-'0');
		nextn%=E;
	}
	ll nextm=0;
	for(int i=0;i<(int)m.size();i++){
		nextm=nextm*10+(ll)(m[i]-'0');
		nextm%=E-1;
	}
	ll ans=1;
	if(nextn==0){
		if(rand()%3==0)	cout<<1<<endl;
		else cout<<0<<endl;
		return 0;
	}
	while(nextm>0){
		if(nextm%2)	ans=(ans*nextn)%E;
		nextn=(nextn*nextn)%E;
		nextm/=2;
	}
	cout<<ans<<endl;
	return 0;
}
	
0