编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#23559 #2030. 喵?喵!喵? Compile Error 0 0 ms 0 K C++ 17 / 1.2 K 192022211866 2024-12-15 22:43:13
显示原始代码
#include <iostream>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;

long long n = 0, q = 0, k = 0;
char ori[1000];

int count(int x) {
    int num = 0;
    int y = x;

    while (true) {
        y /= 2;
        num++;
        if (y == 0 || y == 1)
            break;
    }

    return num;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    cin >> n;

    for (int i = 1; i <= n; i++) cin >> ori[i];

    // cout<<"test0:" << ori << endl;

    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k;
        long long m0 = 0;
        long long m1 = k % n;  //确定组内位置
        if (m1 == 0) {
            m0 = k / n;  //确定ori[k-1]所在的组
            m1 = n;
        } else
            m0 = k / n + 1;  //确定ori[k-1]所在的组

        long long m2 = count(m0);

        /*cout << "test4:"<<m0 << endl;
        cout << "test3:"<<m1 << endl;
        cout << "test1:" << m2 << endl;*/

        long long sum = 0;
        for (int j = m2 - 1; j >= 0; j--) {
            // cout << "test:      " << m0 - pow(2, j) << endl;
            if (m0 - pow(2, j) > 0) {
                m0 -= pow(2, j);
                sum++;
            }
        }

        // cout << "test2:" << sum << endl;

        if (sum % 2 == 1) {
            char ch = ori[m1] + 48;
            cout << ch << endl;
        } else {
            char ch = ori[m1];
            cout << ch << endl;
        }
    }

    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:57:13: error: 'pow' was not declared in this scope
   57 |    if (m0 - pow(2, j) > 0) {
      |             ^~~