結果
| 問題 |
No.1152 10億ゲーム
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-08-09 04:31:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 87 ms / 2,000 ms |
| コード長 | 1,858 bytes |
| コンパイル時間 | 964 ms |
| コンパイル使用メモリ | 95,276 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 26.00 |
| 最終ジャッジ日時 | 2024-07-17 05:43:56 |
| 合計ジャッジ時間 | 7,747 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 50 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1152.cc: No.1152 10億ゲーム - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 10;
/* typedef */
typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;
/* global variables */
int e2s[MAX_N], e5s[MAX_N];
/* subroutines */
inline void getpos(int &x, int &y) {
int p;
scanf("%d", &p);
x = y = 0;
while (p % 2 == 0) x++, p /= 2;
while (p % 5 == 0) y++, p /= 5;
}
inline void putpos(int x, int y) {
printf("%d\n", e2s[x] * e5s[y]); fflush(stdout);
}
inline bool getputpos(int ax, int ay, int &bx, int &by) {
putpos(ax, ay);
if (ax == bx && ay == by) return true;
getpos(bx, by);
return (ax == bx && ay == by);
}
inline int hdist(int x0, int y0, int x1, int y1) {
return abs(x1 - x0) + abs(y1 - y0);
}
/* main */
int main() {
e2s[0] = e5s[0] = 1;
for (int i = 1; i < MAX_N; i++) {
e2s[i] = e2s[i - 1] * 2;
e5s[i] = e5s[i - 1] * 5;
}
int ax, ay, bx, by;
getpos(ax, ay); getpos(bx, by);
while (ax != 7 || ay != 9) {
if (ax < 7) ax++;
else if (ax > 7) ax--;
else if (ay < 9) ay++;
if (getputpos(ax, ay, bx, by)) return 0;
}
if (hdist(ax, ay, bx, by) & 1) {
for (int i = 0; i < 2; i++) {
ax++;
if (getputpos(ax, ay, bx, by)) return 0;
}
}
else {
ax += 2;
if (getputpos(ax, ay, bx, by)) return 0;
}
for (;;) {
int dx = ax - bx, dy = ay - by;
if (dx >= dy) ax--;
else ay--;
if (getputpos(ax, ay, bx, by)) break;
}
return 0;
}
tnakao0123