結果
| 問題 |
No.513 宝探し2
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2017-05-14 21:51:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 658 ms |
| コンパイル使用メモリ | 84,520 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 2.75 |
| 最終ジャッジ日時 | 2024-07-17 01:10:56 |
| 合計ジャッジ時間 | 1,866 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / 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 -*-
*
* 513.cc: No.513 宝探し2 - 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 = 100000;
/* 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