QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#407279#6749. TargetSanCai#Compile Error//C++20921b2024-05-08 14:07:022024-05-08 14:07:03

Judging History

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

  • [2024-05-08 14:07:03]
  • 评测
  • [2024-05-08 14:07:02]
  • 提交

answer

#include <iostream>
#include <algorithm>
#include <cstring>
#define endl '\n'
#define ios ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;
typedef long long LL;

const int N = 4e5 + 10;
const int MOD = 998244353;

vector<int> res;

void solve() {
    double a, b;
    cin >> a >> b;
    int cnt = 0;
    while (a > 1e-4) {
        a *= 0.5;
        cnt++;
    }
    a = 0;
    double s = 0.5;
    while (abs(a - b) > 1e-4) {
        if (a + s > b) {
            res.push_back(1);
        } else {
            res.push_back(2);
            a += s;
        }
        s *= 0.5;
    }
    std::reverse(res.begin(), res.end());
    for (int i = 1; i <= cnt; ++i) {
        cout << 1;
    }
    for (auto i : res) {
        cout << i;
    }
}

signed main() {
    ios;
    int T = 1;
//    cin >> T;
    while (T--) {
        solve();
    }
}

Details

answer.code:12:1: error: ‘vector’ does not name a type
   12 | vector<int> res;
      | ^~~~~~
answer.code: In function ‘void solve()’:
answer.code:26:13: error: ‘res’ was not declared in this scope
   26 |             res.push_back(1);
      |             ^~~
answer.code:28:13: error: ‘res’ was not declared in this scope
   28 |             res.push_back(2);
      |             ^~~
answer.code:33:18: error: ‘res’ was not declared in this scope
   33 |     std::reverse(res.begin(), res.end());
      |                  ^~~