結果

問題 No.514 宝探し3
ユーザー tnakao0123tnakao0123
提出日時 2017-05-14 22:00:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 81,460 KB
実行使用メモリ 24,360 KB
平均クエリ数 2.75
最終ジャッジ日時 2023-09-23 14:02:22
合計ジャッジ時間 2,579 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,228 KB
testcase_01 AC 22 ms
24,300 KB
testcase_02 AC 23 ms
23,820 KB
testcase_03 AC 22 ms
24,348 KB
testcase_04 AC 23 ms
23,580 KB
testcase_05 AC 24 ms
23,616 KB
testcase_06 AC 22 ms
24,084 KB
testcase_07 AC 22 ms
23,868 KB
testcase_08 AC 23 ms
24,360 KB
testcase_09 AC 23 ms
24,060 KB
testcase_10 AC 22 ms
23,652 KB
testcase_11 AC 24 ms
24,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 514.cc: No.514 宝探し3 - 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 N = 1000000000;

/* typedef */

/* global variables */

/* subroutines */

int reqres(int x, int y) {
  printf("%d %d\n", x, y); fflush(stdout);
  int r;
  scanf("%d", &r);
  return r;
}

/* main */

int main() {
  int r0 = reqres(0, 0); // x + y = r0
  if (r0 == 0) return 0;
  int r1 = reqres(N, 0); // y = x - (N - r1)
  if (r1 == 0) return 0;

  // x + y = r0 ..(1)
  // y = x - (N - r1) -> x - y = (N - r1) ..(2)
  // (1)+(2) -> 2*x = r0 - r1 + N -> x = (r0 - r1 + N) /2
  // (1)-(2) -> 2*y = r0 + r1 - N -> y = (r0 + r1 - N) /2

  int x = (r0 - r1 + N) / 2, y = (r0 + r1 - N) / 2;
  printf("%d %d\n", x, y); fflush(stdout);
  return 0;
}
0