結果
問題 | No.2357 Guess the Function |
ユーザー |
|
提出日時 | 2023-06-23 22:09:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 34 ms / 1,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 2,250 ms |
コンパイル使用メモリ | 198,632 KB |
最終ジャッジ日時 | 2025-02-15 01:06:24 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 |
ソースコード
#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