結果
問題 |
No.1152 10億ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-08-07 23:07:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,086 bytes |
コンパイル時間 | 3,128 ms |
コンパイル使用メモリ | 193,432 KB |
最終ジャッジ日時 | 2025-01-12 18:00:35 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; using Int = long long; const char newl = '\n'; template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;} template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);} template<typename T=int> vector<T> read(size_t n){ vector<T> ts(n); for(size_t i=0;i<n;i++) cin>>ts[i]; return ts; } //INSERT ABOVE HERE using P = pair<int, int>; P pos(int x){ int r=0,c=0; while(x%2==0) r++,x/=2; while(x%5==0) c++,x/=5; return P(r,c); } int val(int r,int c){ int x=1; for(int i=0;i<r;i++) x*=2; for(int j=0;j<c;j++) x*=5; return x; } signed main(){ int x1,x2; cin>>x1>>x2; while(1){ auto [r1,c1]=pos(x1); auto [r2,c2]=pos(x2); int ddr=0,ddc=0; if(abs(r2-r1)>abs(c2-c1)){ ddr=(r2-r1)/abs(r2-r1); }else{ ddc=(c2-c1)/abs(c2-c1); } int nr=r1+ddr,nc=c1+ddc; x1=val(nr,nc); cout<<x1<<endl; if(x1==x2) return 0; cin>>x2; if(x1==x2) return 0; } return 0; }