编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#45688 #1149. 1-01E.czq的模k异或 Compile Error 0 0 ms 0 K C++ 17 / 913 B 计试001-顾真榕 2020-08-03 16:24:55
显示原始代码
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
ll xorNum[200001], aAns[200001];
int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    memset(aAns, 0, sizeof(aAns));
    memset(xorNum, 0, sizeof(xorNum));
    ll xorSum = 0;
    for (int i = 0; i < q; i++) {
        ll k, v;
        scanf("%lld %lld", &k, &v);
        if (k > n) {
            printf("%lld\n", xorSum);
            continue;
        }
        xorNum[k] ^= v;
        if (n / k % 2) {
            xorSum ^= v;
        }
        printf("%lld\n", xorSum);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j * j <= i; j++) {
            if (j * j == i) {
                aAns[i] ^= xorNum[j];
            } else if (i % j == 0) {
                aAns[i] ^= xorNum[j] ^ xorNum[i / j];
            }
        }
        printf("%lld ", aAns[i]);
    }
    return 0;
}

编译信息

/sandbox/1/a.cpp: In function 'int main()':
/sandbox/1/a.cpp:9:5: error: 'memset' was not declared in this scope
     memset(aAns, 0, sizeof(aAns));
     ^~~~~~
/sandbox/1/a.cpp:9:5: note: 'memset' is defined in header '<cstring>'; did you forget to '#include <cstring>'?
/sandbox/1/a.cpp:3:1:
+#include <cstring>
 using namespace std;
/sandbox/1/a.cpp:9:5:
     memset(aAns, 0, sizeof(aAns));
     ^~~~~~
/sandbox/1/a.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
     ~~~~~^~~~~~~~~~~~~~~~~
/sandbox/1/a.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &k, &v);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~