結果
問題 |
No.1152 10億ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-08-07 23:25:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,559 bytes |
コンパイル時間 | 2,130 ms |
コンパイル使用メモリ | 193,948 KB |
最終ジャッジ日時 | 2025-01-12 18:28:24 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 WA * 40 |
ソースコード
#include <bits/stdc++.h> using namespace std; using pint = pair<int, int>; #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++) #define REP(i, n) FOR(i,0,n) #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; pint fac(int x) { int i2 = 0, i5 = 0; while (x % 2 == 0) x /= 2, i2++; while (x % 5 == 0) x /= 5, i5++; return pint(i2, i5); } int val(pint p) { int ret = 1; REP(_, p.first) ret *= 2; REP(_, p.second) ret *= 5; return ret; } int main() { int x1, x2; cin >> x1 >> x2; pint p1 = fac(x1), p2 = fac(x2); int cnt = 0; while (true) { if (p1 == p2) return 0; int dist = abs(p1.first - p2.first) + abs(p1.second - p2.second); if (dist == 1) p1 = p2; else if (dist % 2 == 0) { if (p1 == pint(9, 9)) p1 = pint(7, 9); else if (p1 == pint(7, 9)) p1 = pint(9, 9); else if (p1.second < 9) p1.second++; else if (p1.first == 8) p1.first--; else p1.first++; } else { if (p1.first <= p2.first + 1 and p1.first < 9) p1.first++; else if (p1.second <= p2.second + 1 and p1.second < 9) p1.second++; else if (p1.second - p2.second > p1.first - p2.first) p1.second--; else p1.first--; } cnt++; if (cnt >= 36) return 0; cout << val(p1) << endl; if (p1 == p2) return 0; int x; cin >> x; p2 = fac(x); } }