結果
| 問題 |
No.514 宝探し3
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2017-05-14 22:00:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 2,000 ms |
| コード長 | 1,076 bytes |
| コンパイル時間 | 857 ms |
| コンパイル使用メモリ | 83,620 KB |
| 実行使用メモリ | 25,348 KB |
| 平均クエリ数 | 2.75 |
| 最終ジャッジ日時 | 2024-07-16 13:40:56 |
| 合計ジャッジ時間 | 1,937 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int reqres(int, int)’:
main.cpp:40:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
40 | scanf("%d", &r);
| ~~~~~^~~~~~~~~~
ソースコード
/* -*- 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;
}
tnakao0123