結果

問題 No.1152 10億ゲーム
ユーザー ChanyuhChanyuh
提出日時 2020-08-07 23:11:32
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,602 bytes
コンパイル時間 1,460 ms
コンパイル使用メモリ 99,372 KB
実行使用メモリ 43,308 KB
平均クエリ数 18.26
最終ジャッジ日時 2023-09-24 04:59:23
合計ジャッジ時間 8,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
24,348 KB
testcase_01 AC 66 ms
23,676 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 65 ms
23,976 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 65 ms
24,012 KB
testcase_09 AC 66 ms
23,412 KB
testcase_10 AC 66 ms
23,688 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 66 ms
23,844 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 65 ms
23,484 KB
testcase_21 AC 64 ms
24,096 KB
testcase_22 AC 65 ms
24,276 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 TLE -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n=9;
int s1,s2;
int a1=0,b1=0,a2=0,b2=0;

void move(int t){
  if(t==0){
    s1*=2;
    a1+=1;
    return;
  }
  if(t==1){
    s1*=5;
    b1+=1;
    return;
  }
  if(t==2){
    s1/=2;
    a1-=1;
    return;
  }
  if(t==3){
    s1/=5;
    b1-=1;
    return;
  }
}

void apr(int s){
  if(s==0){
    if(a1<a2) {
      a1+=1;
      s1*=2;
    }
    else{
      a1-=1;
      s1/=2;
    }
  }
  else{
    if(b1<b2) {
      b1+=1;
      s1*=5;
    }
    else{
      b1-=1;
      s1/=5;
    }
  }
}


void solve(){
  cin >> s1 >> s2;
  int s1_=s1,s2_=s2;
  while(s1_%2==0){
    a1+=1;
    s1_/=2;
  }
  while(s2_%2==0){
    a2+=1;
    s2_/=2;
  }
  while(s1_%5==0){
    b1+=1;
    s1_/=5;
  }
  while(s2_%5==0){
    b2+=1;
    s2_/=5;
  }
  if(a1<a2){
    s1*=2;
    cout << s1 << endl;
  }
  else if(b1<b2){
    s1*=5;
    cout << s1 << endl;
  }
  else if(a1>a2){
    s1/=2;
    cout << s1 << endl;
  }
  else if(b1>b2){
    s1/=5;
    cout << s1 << endl;
  }
  if(s1==s2) return;
  while(s1!=s2){
    int x;cin >> x;
    if(x==s1) return;
    int t;
    if(x/s2==2){
      t=0;
      s2=x;
      a2+=1;
    }
    else if(x/s2==5){
      t=1;
      s2=x;
      b2+=1;
    }
    else if(s2/x==2){
      t=2;
      s2=x;
      a2-=1;
    }
    else if(s2/x==5){
      t=3;
      s2=x;
      b2-=1;
    }
    else t=4;
    if(t==0 || t==2 || t==4){
      if(a1==a2) apr(1);
      else apr(0);
    }
    if(t==1 || t==3){
      if(b1==b2) apr(0);
      else apr(1);
    }
    cout << s1 << endl;
    if(s1==s2) return;
  }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}
0