結果

問題 No.1429 Simple Dowsing
ユーザー ooooobaoooooba
提出日時 2021-07-18 12:48:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 888 bytes
コンパイル時間 1,057 ms
コンパイル使用メモリ 119,684 KB
実行使用メモリ 24,144 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-24 12:11:52
合計ジャッジ時間 2,499 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,640 KB
testcase_01 AC 25 ms
23,376 KB
testcase_02 AC 25 ms
23,532 KB
testcase_03 AC 24 ms
23,256 KB
testcase_04 AC 23 ms
24,144 KB
testcase_05 AC 25 ms
24,132 KB
testcase_06 AC 23 ms
23,880 KB
testcase_07 AC 23 ms
23,244 KB
testcase_08 AC 23 ms
23,496 KB
testcase_09 AC 25 ms
24,084 KB
testcase_10 AC 24 ms
24,012 KB
testcase_11 AC 24 ms
23,856 KB
testcase_12 AC 23 ms
23,496 KB
testcase_13 AC 25 ms
23,388 KB
testcase_14 AC 24 ms
23,496 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    cout << "? 0 0" << endl;
    int32_t d;
    cin >> d;
    vector<pair<int32_t, int32_t>> cand;
    for (auto a = 0; a <= 100; ++a) {
        for (auto b = 0; b <= 100; ++b) {
            if (a * a + b * b == d) {
                cand.push_back({a, b});
            }
        }
    }
    cout << "? 100 0" << endl;
    cin >> d;
    for (auto &&p : cand) {
        int32_t ta = 100 - p.first, tb = 0 - p.second;
        if (ta * ta + tb * tb == d) {
            cout << "! " << p.first << " " << p.second << endl;
            break;
        }
    }
    return 0;
}
0