結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2020-08-07 23:24:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,588 bytes |
| コンパイル時間 | 3,080 ms |
| コンパイル使用メモリ | 194,076 KB |
| 最終ジャッジ日時 | 2025-01-12 18:27:46 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 8 RE * 29 |
ソースコード
#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 and p1.first < 9) p1.first++;
else if (p1.second <= p2.second and p1.second < 9) p1.second++;
else if (p1.second - 2 > p2.second) p1.second--;
else if (p1.first - 2 > p2.first) p1.first--;
else exit(8);
}
cnt++;
if (cnt >= 36) return 0;
cout << val(p1) << endl;
if (p1 == p2) return 0;
int x;
cin >> x;
p2 = fac(x);
}
}
hitonanode