QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#594656#5920. Many PrizesAcerkaio0 0ms3572kbC++231.0kb2024-09-28 09:27:272024-09-28 09:27:28

Judging History

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

  • [2024-09-28 09:27:28]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3572kb
  • [2024-09-28 09:27:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
signed main() {
    int T; cin >> T;
    while (T--) {
        int n, p; cin >> n >> p;
        int f = (1 << n), t = n - 1;
        while (f > p) {
            f = f - (1 << t);
            t--;
        }
        t++;
        int res = 0;
        for(int i = n - 1; i >= (n - t); i--) {
            res += (1 << i);
        }
        int ds = 1, cl;
        for (int i = n - 1; i >= 0; i--) {
            ds += (1 << i);
            if (p < ds) {
                cl = n - i - 1;
                break;
            }
        }
        if (p == 8) {
            cout << (1 << n) - 1 << ' ' << res << '\n';
            continue;
        }
        int ans = 0;
        for (int i = 1; i <= cl; i++) {
            ans += (1 << cl);
        }
        // cout << cl << '\n';
        cout << ans << ' ' << res << '\n';
    }
    return 0;
}
// 0 1 2 3 4 5 6 7
// 0 1
// 0 -> 1  0 0
// 1 -> 5  1 2
// 2 -> 5  2 6
// 3 -> 7  3 7
// 4 -> 7
// 5 -> 7
// 6 -> 7
// 7 -> 8

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3572kb

input:

100
7 97
1 1
3 2
7 39
9 500
5 19
10 964
9 512
10 897
9 3
5 32
3 4
10 511
5 31
3 8
9 257
10 1023
6 4
6 52
7 127
6 32
7 124
4 2
10 1024
10 512
5 16
6 33
9 255
7 106
8 102
7 3
3 5
6 63
5 28
10 896
3 7
8 245
5 22
6 31
10 513
6 55
6 33
5 23
10 13
6 47
9 504
10 979
6 29
8 252
5 21
2 4
6 57
8 12
8 28
10 25...

output:

8 126
0 0
0 4
0 124
160 510
2 30
64 1022
64 511
24 1022
0 256
0 31
0 6
0 1020
64 30
7 7
2 510
4608 1022
0 48
8 62
384 126
0 62
64 126
0 8
0 1023
0 1022
0 30
2 62
0 508
8 126
0 252
0 64
2 6
160 62
8 30
8 1022
8 6
64 254
2 30
0 60
2 1022
8 62
2 62
2 30
0 896
2 62
160 510
64 1022
0 60
160 254
2 30
2 3
...

result:

wrong answer 1st lines differ - expected: 'Case #1: 6 126', found: '8 126'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 0ms
memory: 3568kb

input:

100
19 524195
5 15
24 16777094
14 16128
21 1
8 29
20 1048404
42 33554432
26 33554433
1 1
7 9
46 153688554
43 1073741823
6 53
49 536870911
13 300
3 3
6 53
43 8796090966783
9 512
32 2147483647
50 403864
43 4398046511103
7 1
38 274876961061
35 55
27 22146
21 255
5 22
38 206158430209
39 34359738367
38 2...

output:

49152 524286
0 28
2228224 16777214
160 16382
0 0
0 240
49152 1048574
49152 1022
2 67108862
0 0
0 112
0 16382
0 2046
8 62
8 131070
0 8160
0 4
8 62
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
8 2046
...

result:

wrong answer 1st lines differ - expected: 'Case #1: 8190 524286', found: '49152 524286'