编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#290 #1001. A. 神秘谜题 Time Limit Exceeded 0 2085 ms 360 K C++ / 1.8 K galaxy 2019-06-24 14:48:34
显示原始代码
#include <string>
#include <stdio.h>
#include <iostream>
#include <stack>
#include <math.h>
using namespace std;
#define max(a, b) a >= b ? a : b

int change_to_bin(int num) {
    int result = 0, k = 1, i, n;
    n = num;
    while (n) {
        i = n % 2;
        result += k * i;
        k *= 10;
        n /= 2;
    }
    // printf("%d\n",result);
    return (result);
}
int change_to_decimal(int num) {
    int result = 0, n, i, j = 0;
    n = num;
    while (n) {
        i = n % 10;
        result += i * pow(2, j);
        // printf("result:%d,i=:%d\n",result,i);
        j += 1;
        n /= 10;
    }
    // printf("%d",result);
    return (result);
}

int my_xor(int a, int b) {
    int i, aa, bb, lena = 1, lenb = 1, len, k = 10, result = 0;
    aa = change_to_bin(a);
    bb = change_to_bin(b);
    while (aa / k) {
        lena += 1;
        k *= 10;
    }
    while (bb / k) {
        lenb += 1;
        k *= 10;
    }
    len = max(lena, lenb);
    // printf("len:%d\n",len);
    k = 1;
    for (i = 0; i < len; i++) {
        result += k * ((aa % (k * 10) / k) ^ (bb % (k * 10) / k));
        // if(k==1)result+=k*((aa%(k*10))^(bb%(k*10)));
        //		printf("(aa%(k*10)):%d,(bb%(k*10))=:%d\n",(aa%(k*10)),(bb%(k*10)));
        //		printf("???%d???\n",((aa%(k*10))^(bb%(k*10))));
        //		printf("result:%d,k=:%d\n",result,k);
        k *= 10;
    }
    // printf("%d",result);
    result = change_to_decimal(result);
    return (result);
}
int main() {
    int n, i, j, num_list = 0, act_num, act_bin, con;
    int mid;  //定义中间变量,用于便利计算异或。之前异或写的是两两之间。
    scanf("%d", &n);
    act_num = 0;
    int act[n], list[n];
    while (act_num < n) {  //这个是操作数要少于输入的第一个

        scanf("%d", &act_bin);  //输入操作类型,1或者2
        if (act_bin == 2) {
            scanf("%d", &con);  //输入要加入的数字
            list[num_list] = con;
            num_list += 1;
            act_num += 1;
        }
        if (act_bin == 1) {
            for (j = 0; j < num_list; j++) list[j] += 1;  //全部都加一
            act_num += 1;
        }
        mid = list[0];
        for (j = 1; j < num_list; j++) {
            mid = my_xor(mid, list[j]);
        }
        printf("%d\n", mid);
    }
}
子任务 #1
Time Limit Exceeded
得分:0
测试点 #1
Time Limit Exceeded
得分:0
用时:1034 ms
内存:360 KiB

输入文件(1.in

200000
2 526767110
2 724642759
2 567837900
2 104106873
2 357915481
2 33997211
2 444788944
2 
<1586974 bytes omitted>

答案文件(1.ans

526767110
877985729
361528077
330887284
116239149
82537142
510237286
843295274
453728745
55
<2188330 bytes omitted>

用户输出

526767110
1837
2417
1912
-3511
2674
1658
3122
-3103
1073
758
3578
2642
3901
1626
4101
2559
3078
3929
-2603
3184
-1530
-2023
1958
<8064 bytes omitted>
测试点 #2
Time Limit Exceeded
得分:0
用时:1051 ms
内存:292 KiB

输入文件(2.in

200000
2 515979308
2 512702340
2 684230440
2 488136957
2 598252313
2 283603971
2 349877373
2
<1586842 bytes omitted>

答案文件(2.ans

515979308
5115816
679905408
899606653
372667236
114362215
302756634
473674072
520218589
525
<2192841 bytes omitted>

用户输出

515979308
1952
-3208
-3827
-2412
-2821
-3894
-2772
-3767
1241
-2662
1668
3295
2157
-2156
1439
-1630
-896
-3933
-1714
-2416
-1605
<8064 bytes omitted>