結果
| 問題 |
No.251 大きな桁の復習問題(1)
|
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2015-07-25 00:00:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 581 bytes |
| コンパイル時間 | 1,437 ms |
| コンパイル使用メモリ | 160,956 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-16 01:03:30 |
| 合計ジャッジ時間 | 1,926 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 1 |
ソースコード
#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(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;
}
fiord