結果
問題 | No.2357 Guess the Function |
ユーザー |
|
提出日時 | 2023-06-23 21:46:16 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 25 ms / 1,000 ms |
コード長 | 1,373 bytes |
コンパイル時間 | 3,277 ms |
コンパイル使用メモリ | 254,056 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 3.00 |
最終ジャッジ日時 | 2024-07-01 01:21:49 |
合計ジャッジ時間 | 4,157 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifdef LOCAL#include "debug.hpp"#else#define debug(...) 1#endifstruct xorshift {using u32 = uint32_t;u32 x = 123456789, y = 362436069, z = 521288629, w = 88675123;xorshift(u32 seed = 0) { z ^= seed; }u32 operator()() {u32 t = x ^ (x << 11);x = y;y = z;z = w;return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));}} rnd;int randint(int l, int r) {return l + rnd() % (r - l + 1);}int main() {ios::sync_with_stdio(false);cin.tie(nullptr);auto Ask = [&] (int x) {cout << "? " << x << endl;int ret;cin >> ret;return ret;};int y1 = Ask(100);vector<pair<int, int>> can;for (int a = 0; a < 100; a++) {for (int b = a + 1; b <= 100; b++) {if ((a + 100) % b == y1) {can.push_back(make_pair(a, b));}}}for (int i = 1; i <= 100; i++) {set<int> z;for (auto [u, v] : can) {z.insert((u + i) % v);}if (can.size() == z.size()) {int y2 = Ask(i);for (auto [u, v] : can) {if (y2 == (u + i) % v) {cout << "! " << u << ' ' << v << endl;return 0;}}}}}