QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#594691 | #5920. Many Prizes | Acerkaio | 20 ✓ | 1ms | 3724kb | C++23 | 1.4kb | 2024-09-28 09:43:25 | 2024-09-28 09:43:25 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int T; cin >> T;
int cnt = 0;
while (T--) {
cnt++;
int n, p; cin >> n >> p;
int f = (1ll << n), t = n - 1ll;
// if (cnt == 8) {
// cout << f << ' ' << t << "???\n";
// }
while (f > p) {
f = f - (1ll << t);
t--;
}
t++;
int res = 0;
for(int i = n - 1ll; i >= (n - t); i--) {
res += (1ll << i);
}
int ds = 1ll, cl;
for (int i = n - 1ll; i >= 0; i--) {
ds += (1ll << i);
if (p < ds) {
cl = n - i - 1ll;
break;
}
}
if (p == (1ll << n)) {
cout << "Case #" << cnt << ": " << (1ll << n) - 1ll << ' ' << res << '\n';
continue;
}
int ans = 0;
// cout << ans << '\n';
for (int i = 1ll; i <= cl; i++) {
ans += (1ll << i);
}
// cout << "????" << ans << '\n';
// cout << cl << '\n';
cout << "Case #" << cnt << ": " << ans << ' ' << res << '\n';
}
return 0;
}
// 0 1ll 2 3 4 5 6 7
// 0 1ll
// 0 -> 1ll 0 0
// 1ll -> 5 1ll 2
// 2 -> 5 2 6
// 3 -> 7 3 7
// 4 -> 7
// 5 -> 7
// 6 -> 7
// 7 -> 8
詳細信息
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 1ms
memory: 3576kb
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:
Case #1: 6 126 Case #2: 0 0 Case #3: 0 4 Case #4: 0 124 Case #5: 62 510 Case #6: 2 30 Case #7: 30 1022 Case #8: 511 511 Case #9: 14 1022 Case #10: 0 256 Case #11: 31 31 Case #12: 0 6 Case #13: 0 1020 Case #14: 30 30 Case #15: 7 7 Case #16: 2 510 Case #17: 1022 1022 Case #18: 0 48 Case #19: 6 62 Case...
result:
ok 100 lines
Subtask #2:
score: 13
Accepted
Test #2:
score: 13
Accepted
time: 1ms
memory: 3724kb
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:
Case #1: 8190 524286 Case #2: 0 28 Case #3: 262142 16777214 Case #4: 62 16382 Case #5: 0 0 Case #6: 0 240 Case #7: 8190 1048574 Case #8: 0 4398046380032 Case #9: 2 67108862 Case #10: 0 0 Case #11: 0 112 Case #12: 0 70368743653376 Case #13: 0 8796093005824 Case #14: 6 62 Case #15: 0 562949951324160 C...
result:
ok 100 lines
Extra Test:
score: 0
Extra Test Passed