結果

問題 No.1152 10億ゲーム
ユーザー RubikunRubikun
提出日時 2020-08-07 22:41:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,099 bytes
コンパイル時間 1,421 ms
コンパイル使用メモリ 175,172 KB
実行使用メモリ 24,396 KB
平均クエリ数 23.82
最終ジャッジ日時 2023-09-24 04:44:21
合計ジャッジ時間 6,517 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
24,228 KB
testcase_01 AC 55 ms
24,252 KB
testcase_02 AC 55 ms
23,988 KB
testcase_03 AC 55 ms
23,352 KB
testcase_04 AC 53 ms
23,388 KB
testcase_05 AC 55 ms
23,508 KB
testcase_06 AC 54 ms
24,240 KB
testcase_07 AC 57 ms
23,604 KB
testcase_08 AC 54 ms
23,784 KB
testcase_09 AC 56 ms
24,012 KB
testcase_10 AC 54 ms
23,496 KB
testcase_11 AC 55 ms
24,216 KB
testcase_12 AC 56 ms
24,396 KB
testcase_13 AC 56 ms
23,628 KB
testcase_14 AC 58 ms
23,556 KB
testcase_15 AC 56 ms
24,000 KB
testcase_16 AC 53 ms
24,348 KB
testcase_17 AC 55 ms
23,640 KB
testcase_18 AC 56 ms
24,252 KB
testcase_19 AC 57 ms
23,340 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 55 ms
23,988 KB
testcase_23 AC 60 ms
23,376 KB
testcase_24 AC 56 ms
23,604 KB
testcase_25 AC 56 ms
23,592 KB
testcase_26 AC 58 ms
23,976 KB
testcase_27 AC 58 ms
24,000 KB
testcase_28 AC 57 ms
23,400 KB
testcase_29 AC 56 ms
23,508 KB
testcase_30 AC 54 ms
23,976 KB
testcase_31 AC 56 ms
24,000 KB
testcase_32 AC 55 ms
24,192 KB
testcase_33 AC 55 ms
24,240 KB
testcase_34 AC 55 ms
23,640 KB
testcase_35 AC 57 ms
23,976 KB
testcase_36 AC 57 ms
24,204 KB
testcase_37 AC 55 ms
24,192 KB
testcase_38 AC 54 ms
23,388 KB
testcase_39 AC 54 ms
24,012 KB
testcase_40 AC 54 ms
23,496 KB
testcase_41 AC 53 ms
24,240 KB
testcase_42 AC 54 ms
23,796 KB
testcase_43 AC 53 ms
23,976 KB
testcase_44 AC 54 ms
23,568 KB
testcase_45 AC 53 ms
24,024 KB
testcase_46 AC 53 ms
23,376 KB
testcase_47 AC 55 ms
23,568 KB
testcase_48 AC 52 ms
23,352 KB
testcase_49 AC 53 ms
23,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    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(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){
                break;
            }else{
                cout<<D/4<<endl;
                x1=D/4;
            }
        }else if(x1==D/4){
            if(pa){
                break;
            }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(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;
        
        if(x1==x2) return 0;
        
        t++;
        
    }
}
0