結果

問題 No.2357 Guess the Function
ユーザー t33ft33f
提出日時 2023-06-24 14:32:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 927 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 68,644 KB
実行使用メモリ 24,360 KB
平均クエリ数 1.00
最終ジャッジ日時 2023-09-14 09:48:39
合計ジャッジ時間 2,916 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <iostream>
using namespace std;

#define TEST

int query(int);
void answer(int, int);

void solve() {
    const int r = query(100);
    if (r == 99) {
        answer(99, 100);
    } else {
        const int s = query(100 - r - 1);
        const int B = s + 1;
        answer(((r - 100) % B + B) % B, B);
    }
}

#ifdef TEST

int A, B;
void init(int a, int b) { A = a; B = b; }
int query(int x) {
    return (x + A) % B;
}

void answer(int a, int b) {
    cerr << A << ' ' << B << ' ' << a << ' ' << b << endl;
    assert(a == A && b == B);
}

int main() {
    for (int a = 0; a < 100; ++a)
        for (int b = a + 1; b <= 100; ++b) {
            init(a, b);
            solve();
        }
}

#else

int query(int x) {
    cout << "? " << x << endl;
    int r; cin >> r;
    return r;
}

void answer(int a, int b) {
    cout << "! " << a << ' ' << b << endl;
}

int main() {
    solve();
}

#endif
0