結果

問題 No.1152 10億ゲーム
ユーザー snow39snow39
提出日時 2020-10-16 19:18:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,555 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 93,092 KB
実行使用メモリ 45,204 KB
平均クエリ数 2.28
最終ジャッジ日時 2023-09-24 06:52:06
合計ジャッジ時間 5,689 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
24,012 KB
testcase_01 AC 67 ms
23,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 66 ms
24,084 KB
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
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 <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int fivN(int x){
  int res=0;
  while(x%5==0){
    res++;
    x/=5;
  }
  return res;
}
int twoN(int x){
  int res=0;
  while(x%2==0){
    res++;
    x/=2;
  }
  return res;
}

void output(int x,int y){
  int res=1;
  rep(i,x) res*=2;
  rep(i,y) res*=5;
  cout<<res<<endl;
}

const int L=9;

int main(){
  int S,T;
  cin>>S>>T;

  bool ED=false;
  vector<int> A(2),B(2);
  A[0]=twoN(S);
  A[1]=fivN(S);
  B[0]=twoN(T);
  B[1]=fivN(T);
  while(1){
    if(A[0]==B[0]&&A[1]==B[1]){
      exit(0);
    }
    if(A[0]==B[0]&&abs(A[1]-B[1])==1){
      output(B[0],B[1]);
      exit(0);
    }
    if(abs(A[0]-B[0])==1&&A[1]==B[1]){
      output(B[0],B[1]);
      exit(0);
    }

    if(ED){
      if(A[0]-B[0]>A[1]-B[1]) output(--A[0],A[1]);
      else output(A[0],--A[1]);
    }else{
      if(A[0]==L&&A[1]==L){
        ED=true;
        if(A[0]-B[0]>A[1]-B[1]) output(--A[0],A[1]);
        else output(A[0],--A[1]);
      }else if(A[0]<L) output(++A[0],A[1]);
      else output(A[0],++A[1]);
    }

    int X;
    cin>>X;
    B[0]=twoN(X);
    B[1]=fivN(X);
  }

  return 0;
}
0