結果

問題 No.251 大きな桁の復習問題(1)
ユーザー fiord
提出日時 2015-07-25 00:05:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 1,389 ms
コンパイル使用メモリ 160,900 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-16 02:14:51
合計ジャッジ時間 2,383 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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(){
	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(nextm==0&&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