結果

問題 No.1152 10億ゲーム
ユーザー 👑 emthrmemthrm
提出日時 2020-08-09 01:15:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 2,175 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 201,296 KB
実行使用メモリ 24,372 KB
平均クエリ数 26.00
最終ジャッジ日時 2023-09-24 05:27:42
合計ジャッジ時間 8,488 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
24,372 KB
testcase_01 AC 65 ms
24,036 KB
testcase_02 AC 67 ms
23,376 KB
testcase_03 AC 66 ms
23,364 KB
testcase_04 AC 65 ms
23,628 KB
testcase_05 AC 66 ms
23,400 KB
testcase_06 AC 66 ms
23,640 KB
testcase_07 AC 67 ms
23,820 KB
testcase_08 AC 65 ms
23,520 KB
testcase_09 AC 64 ms
24,372 KB
testcase_10 AC 63 ms
23,628 KB
testcase_11 AC 65 ms
23,352 KB
testcase_12 AC 65 ms
23,616 KB
testcase_13 AC 66 ms
23,616 KB
testcase_14 AC 65 ms
23,640 KB
testcase_15 AC 65 ms
23,832 KB
testcase_16 AC 63 ms
23,628 KB
testcase_17 AC 64 ms
24,048 KB
testcase_18 AC 66 ms
24,360 KB
testcase_19 AC 65 ms
23,508 KB
testcase_20 AC 64 ms
23,640 KB
testcase_21 AC 64 ms
23,520 KB
testcase_22 AC 63 ms
23,616 KB
testcase_23 AC 64 ms
23,820 KB
testcase_24 AC 66 ms
23,988 KB
testcase_25 AC 66 ms
23,364 KB
testcase_26 AC 64 ms
23,364 KB
testcase_27 AC 64 ms
23,640 KB
testcase_28 AC 64 ms
23,652 KB
testcase_29 AC 64 ms
24,348 KB
testcase_30 AC 65 ms
23,832 KB
testcase_31 AC 64 ms
23,820 KB
testcase_32 AC 64 ms
24,036 KB
testcase_33 AC 66 ms
23,700 KB
testcase_34 AC 65 ms
23,364 KB
testcase_35 AC 64 ms
23,364 KB
testcase_36 AC 64 ms
24,048 KB
testcase_37 AC 64 ms
24,348 KB
testcase_38 AC 63 ms
24,360 KB
testcase_39 AC 63 ms
24,048 KB
testcase_40 AC 64 ms
23,352 KB
testcase_41 AC 64 ms
24,324 KB
testcase_42 AC 64 ms
23,376 KB
testcase_43 AC 64 ms
23,388 KB
testcase_44 AC 63 ms
24,000 KB
testcase_45 AC 64 ms
24,048 KB
testcase_46 AC 65 ms
24,036 KB
testcase_47 AC 64 ms
23,808 KB
testcase_48 AC 64 ms
23,616 KB
testcase_49 AC 65 ms
23,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

pair<int, int> f(int x) {
  int a = 0, b = 0;
  while (x % 2 == 0) {
    ++a;
    x /= 2;
  }
  while (x % 5 == 0) {
    ++b;
    x /= 5;
  }
  return {a, b};
}

int g(pair<int, int> p) {
  auto [a, b] = p;
  int res = 1;
  REP(_, a) res *= 2;
  REP(_, b) res *= 5;
  return res;
}

int dist(pair<int, int> p1, pair<int, int> p2) {
  return abs(p1.first - p2.first) + abs(p1.second - p2.second);
}

int main() {
  int x1, x2; cin >> x1 >> x2;
  auto p1 = f(x1);
  while (p1.first != 7) {
    p1.first += p1.first > 7 ? -1 : 1;
    x1 = g(p1);
    cout << x1 << endl;
    if (x1 == x2) return 0;
    cin >> x2;
    if (x1 == x2) return 0;
  }
  while (p1.second != 9) {
    ++p1.second;
    x1 = g(p1);
    cout << x1 << endl;
    if (x1 == x2) return 0;
    cin >> x2;
    if (x1 == x2) return 0;
  }
  auto p2 = f(x2);
  if (dist(p1, p2) & 1) {
    x1 = 500000000;
    cout << x1 << endl;
    if (x1 == x2) return 0;
    cin >> x2;
    if (x1 == x2) return 0;
  }
  x1 = 1000000000;
  p1 = {9, 9};
  cout << x1 << endl;
  if (x1 == x2) return 0;
  cin >> x2;
  if (x1 == x2) return 0;
  p2 = f(x2);
  while (true) {
    (p1.first - p2.first > p1.second - p2.second ? p1.first : p1.second) -= 1;
    x1 = g(p1);
    cout << x1 << endl;
    if (x1 == x2) return 0;
    cin >> x2;
    p2 = f(x2);
    if (x1 == x2) return 0;
  }
}
0