結果

問題 No.2357 Guess the Function
ユーザー as277575as277575
提出日時 2023-06-23 22:51:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,038 bytes
コンパイル時間 1,290 ms
コンパイル使用メモリ 128,500 KB
実行使用メモリ 24,300 KB
平均クエリ数 4.00
最終ジャッジ日時 2023-09-13 17:58:15
合計ジャッジ時間 2,810 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 <algorithm>
#include <bit>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <set>
#include <string>

using namespace::std;

template <typename T>
void print(const T& v) {
 for (const auto& x : v) cout << x << " ";
 cout << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cout << "? 50" << endl;
  int u;
  cin >> u;
  
  vector<pair<int, int>> p;
  for (int a = 0; a < 100; ++a)
    for (int b = a + 1; b <= 100; ++b)
      if ((a + 50) % b == u)
        p.push_back({a, b});
        
  int y = 1;
  unordered_map<int, pair<int, int>> m;
  for (; y <= 100; ++y) {
    for (const auto& [a, b] : p)
      m[(a + y) % b] = {a, b};
    if (m.size() == p.size()) { cout << "pre y " << y << endl; break;}
    else m.clear();
  }
  cout << "? " << y << endl;
  int w;
  cin >> w;
  cout << "! " << m[w].first << " " << m[w].second << endl;
  
  return 0;
}

0