QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304951#5471. Interactive Number GuessingSultanAACompile Error//C++20858b2024-01-14 07:51:382024-01-14 07:51:38

Judging History

你现在查看的是最新测评结果

  • [2024-01-14 07:51:38]
  • 评测
  • [2024-01-14 07:51:38]
  • 提交

answer

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

int main() {
   int d;
   cout << "query 0\n";
   cout.flush(); cin >> d;
   string ans = "";
   
   for (int digit = 0; digit <= 17; digit++) {
      int l = 1, r = 10;
      while(r >= l) {
         int mid = (l+r)/2;
         if (mid == 10 && digit == 17) {l = 10; break}
         int digitsum;
         cout << "query " << mid << string(digit, '0') << "\n"; cout.flush();
         cin >> digitsum;
         if (digitsum > d) l = mid+1;
         if (digitsum <= d) r = mid-1;
      }
      
      // cout << l << " " << r << "\n";
      ans.push_back(10 - min(l,10) + '0');
   }
   
   reverse(ans.begin(), ans.end());
   bool number = false;
   for (char c : ans) {
      if (c != '0' || number) {
         number = true; cout << c;
      }
   }
}

Details

answer.code: In function ‘int main()’:
answer.code:15:54: error: expected ‘;’ before ‘}’ token
   15 |          if (mid == 10 && digit == 17) {l = 10; break}
      |                                                      ^
      |                                                      ;