結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2020-08-07 22:37:16 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,202 bytes |
| コンパイル時間 | 1,789 ms |
| コンパイル使用メモリ | 176,472 KB |
| 実行使用メモリ | 25,472 KB |
| 平均クエリ数 | 24.24 |
| 最終ジャッジ日時 | 2024-07-17 04:56:37 |
| 合計ジャッジ時間 | 8,574 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 48 WA * 2 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30,D=1000000000;
int main(){
int x1,x2;cin>>x1>>x2;
map<int,int> MA,MA2,MA5;
for(int i=0;i<10;i++){
for(int j=0;j<10;j++){
int a=1;
for(int k=0;k<i;k++) a*=2;
for(int k=0;k<j;k++) a*=5;
MA[a]=i+j;
MA2[a]=i;
MA5[a]=j;
}
}
int t=0;
while(1){
if(t>35){
for(int q=0;q<D;){
}
}
if(x1/2==x2||x1/5==x2||x1*2==x2||x1*5==x2||(x1==D/4&&x2==D)){
cout<<x2<<endl;
return 0;
}
int pa=abs(MA[x1]-MA[x2])&1;
if(x1==D&&pa) break;
if(x1==D/2){
if(pa){
cout<<D<<endl;
x1=D;
}else{
cout<<D/4<<endl;
x1=D/4;
}
}else if(x1==D/4){
if(pa){
cout<<D/2<<endl;
x1=D/2;
}else{
cout<<D<<endl;
x1=D;
}
}else if(MA2[x1]>=8){
cout<<x1/2<<endl;
x1/=2;
}else if(MA2[x1]<7){
cout<<x1*2<<endl;
x1*=2;
}else{
cout<<x1*5<<endl;
x1*=5;
}
if(x1==x2) return 0;
cin>>x2;
t++;
if(x1==x2) return 0;
}
while(1){
if(t>35){
for(int q=0;q<D;){
}
}
if(x1/2==x2||x1/5==x2||x1*2==x2||x1*5==x2||(x1==D/4&&x2==D)){
cout<<x2<<endl;
return 0;
}
int a=MA2[x1]-MA2[x2],b=MA5[x1]-MA5[x2];
if(x1==D){
cout<<x1/2<<endl;
x1/=2;
}else if(x1==D/2){
cout<<x1/2<<endl;
x1/=2;
}else if(abs(a)==1){
if(b>0){
cout<<x1/5<<endl;
x1/=5;
}else{
cout<<x1*5<<endl;
x1*=5;
}
}else if(abs(b)==1){
if(a>0){
cout<<x1/2<<endl;
x1/=2;
}else{
cout<<x1*2<<endl;
x1*=2;
}
}else if(abs(a)&1){
if(a>0){
cout<<x1/2<<endl;
x1/=2;
}else{
cout<<x1*2<<endl;
x1*=2;
}
}else if(abs(b)&1){
if(b>0){
cout<<x1/5<<endl;
x1/=5;
}else{
cout<<x1*5<<endl;
x1*=5;
}
}
cin>>x2;
t++;
}
}
Rubikun