結果
問題 | No.1152 10億ゲーム |
ユーザー |
![]() |
提出日時 | 2020-10-16 19:18:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,555 bytes |
コンパイル時間 | 902 ms |
コンパイル使用メモリ | 95,876 KB |
実行使用メモリ | 52,152 KB |
平均クエリ数 | 2.28 |
最終ジャッジ日時 | 2024-07-17 07:10:19 |
合計ジャッジ時間 | 5,264 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 WA * 3 TLE * 1 -- * 43 |
ソースコード
#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; }