結果

問題 No.2357 Guess the Function
ユーザー luanmengleiluanmenglei
提出日時 2023-06-23 22:09:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 1,000 ms
コード長 986 bytes
コンパイル時間 1,943 ms
コンパイル使用メモリ 203,748 KB
実行使用メモリ 24,168 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-13 17:10:36
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,568 KB
testcase_01 AC 23 ms
23,832 KB
testcase_02 AC 22 ms
23,640 KB
testcase_03 AC 22 ms
23,544 KB
testcase_04 AC 22 ms
23,652 KB
testcase_05 AC 22 ms
23,292 KB
testcase_06 AC 22 ms
23,760 KB
testcase_07 AC 23 ms
23,532 KB
testcase_08 AC 23 ms
23,544 KB
testcase_09 AC 25 ms
24,168 KB
testcase_10 AC 22 ms
23,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) {
	return uniform_int_distribution<>(l, r)(rng);
}

int cnt[101];

int main() {
	int c = 51;
	cout << "? " << c << endl;
	int x;
	cin >> x;
	vector<pair<int, int>> posb;
	for (int a = 0; a <= 100; a ++) {
		for (int b = a + 1; b <= 100; b ++) {
			if ((a + c) % b == x) {
				posb.emplace_back(a, b);
			}
		}
	}
	for (int d = 1; d <= 100; d ++) {
		auto solve = [&]() {
			for (int i = 0; i <= 100; i ++) cnt[i] = 0;
			for (auto [a, b] : posb) cnt[(a + d) % b] ++;
			for (int i = 0; i <= 100; i ++) if (cnt[i] > 1) {
				// cout << "d: " << d << " cnt: " << cnt[i] << "\n";

				return false;
			}
			cout << "? " << d << endl;
			int y; cin >> y;
			for (auto [a, b] : posb) {
				if ((a + d) % b == y) {
					cout << "! " << a << " " << b;
					break;
				}
			}
			return true;
		};
		if (solve()) {
			return 0;
		}
	}
	return 0;
}
// 7 10
0