結果

問題 No.1152 10億ゲーム
ユーザー Shun_PIShun_PI
提出日時 2020-08-07 23:00:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,778 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 165,008 KB
実行使用メモリ 24,384 KB
平均クエリ数 22.98
最終ジャッジ日時 2023-09-24 04:54:21
合計ジャッジ時間 6,459 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
24,240 KB
testcase_01 AC 53 ms
23,628 KB
testcase_02 AC 58 ms
23,604 KB
testcase_03 AC 57 ms
23,928 KB
testcase_04 AC 58 ms
23,592 KB
testcase_05 AC 59 ms
23,352 KB
testcase_06 AC 54 ms
24,144 KB
testcase_07 AC 54 ms
23,976 KB
testcase_08 AC 53 ms
23,604 KB
testcase_09 AC 52 ms
23,964 KB
testcase_10 AC 53 ms
24,240 KB
testcase_11 AC 55 ms
24,156 KB
testcase_12 AC 56 ms
23,340 KB
testcase_13 AC 58 ms
24,240 KB
testcase_14 AC 60 ms
23,352 KB
testcase_15 AC 59 ms
23,340 KB
testcase_16 AC 56 ms
23,304 KB
testcase_17 AC 55 ms
23,484 KB
testcase_18 AC 54 ms
23,376 KB
testcase_19 AC 54 ms
24,264 KB
testcase_20 AC 54 ms
23,472 KB
testcase_21 AC 53 ms
24,204 KB
testcase_22 AC 53 ms
23,760 KB
testcase_23 AC 58 ms
23,496 KB
testcase_24 AC 54 ms
23,568 KB
testcase_25 AC 54 ms
23,592 KB
testcase_26 AC 54 ms
23,772 KB
testcase_27 AC 55 ms
23,604 KB
testcase_28 AC 55 ms
23,988 KB
testcase_29 AC 53 ms
23,604 KB
testcase_30 AC 54 ms
23,376 KB
testcase_31 AC 54 ms
24,384 KB
testcase_32 AC 53 ms
24,252 KB
testcase_33 AC 54 ms
23,328 KB
testcase_34 AC 54 ms
23,784 KB
testcase_35 AC 59 ms
23,604 KB
testcase_36 AC 60 ms
23,328 KB
testcase_37 AC 61 ms
23,316 KB
testcase_38 AC 55 ms
23,568 KB
testcase_39 AC 56 ms
24,252 KB
testcase_40 AC 55 ms
23,484 KB
testcase_41 AC 54 ms
23,796 KB
testcase_42 AC 53 ms
23,484 KB
testcase_43 AC 54 ms
24,012 KB
testcase_44 AC 55 ms
23,376 KB
testcase_45 AC 56 ms
23,340 KB
testcase_46 AC 58 ms
23,976 KB
testcase_47 AC 57 ms
23,484 KB
testcase_48 AC 55 ms
23,964 KB
testcase_49 AC 53 ms
24,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
void outnum(int two, int five) {
  int ans = 1;
  REP(i, two) ans *= 2;
  REP(i, five) ans *= 5;
  cout << ans << "\n";
  cout.flush();
}
int gettwo(int num) {
  int two = 0;
  while(num%2 == 0) {
    num /= 2;
    two++;
  }
  return two;
}
int getfive(int num) {
  int five = 0;
  while(num%5 == 0) {
    num /= 5;
    five++;
  }
  return five;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int x1, x2;
  cin >> x1 >> x2;
  int two1 = gettwo(x1);
  int five1 = getfive(x1);
  int two2 = gettwo(x2);
  int five2 = getfive(x2);
  while(true) {
    if((abs(two1-two2) + abs(five1-five2))%2 == 0) {
      if(two1 < 7) two1++;
      else if(two1 > 7) two1--;
      else if(five1 < 9) five1++;
      else two1 += 2;
    } else {
      if(five1 == five2 && abs(two1-two2) == 1) two1 = two2;
      else if(two1 == two2 && abs(five1-five2) == 1) five1 = five2;
      else if(abs(two1-two2) > abs(five1-five2)) {
        if(two1 > two2) two1--;
        else two1++;
      } else {
        if(five1 > five2) five1--;
        else five1++;
      }
    }
    outnum(two1, five1);
    if(two1 == two2 && five1 == five2) break;
    cin >> x2;
    two2 = gettwo(x2);
    five2 = getfive(x2);
    if(two1 == two2 && five1 == five2) break;
  }
    
}
0