QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#145294 | #4184. Amusement Arcade | Asuna | WA | 1ms | 3704kb | C++20 | 820b | 2023-08-22 03:48:35 | 2023-08-22 03:48:37 |
Judging History
answer
#include <algorithm>
#include <iostream>
bool judge1(long long int n) {
for(int i = 0;i <= 60;++i) {
if ((1ll << i) + 1 == n) {
return true;
}
}
return false;
}
bool judge2(long long int n) {
for(int i = 0;i <= 60;++i) {
for(int j = i + 1;j <= 60;++j) {
if ((1ll << i) + (1ll << j) + 1 == n) {
return true;
}
}
}
return false;
}
void solve() {
long long int n;
std::cin >> n;
if (judge1(n)) {
std::cout << (n / 2) + 1 << "\n";
} else if (judge2(n)) {
n -= 1;
// 找第一个 1 位置
std::cout << (n & (-n)) + 1 << "\n";
} else {
std::cout << "impossible\n";
}
}
int main() {
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3628kb
input:
7
output:
3
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3508kb
input:
15
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
19
output:
3
result:
ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
2049
output:
1025
result:
ok
Test #5:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
32769
output:
16385
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
536870913
output:
268435457
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
35184372088833
output:
17592186044417
result:
ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
2251799813685249
output:
1125899906842625
result:
ok
Test #9:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
576460752303423489
output:
288230376151711745
result:
ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
1027
output:
3
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
2081
output:
33
result:
ok
Test #12:
score: 0
Accepted
time: 1ms
memory: 3648kb
input:
34393292801
output:
33554433
result:
ok
Test #13:
score: -100
Wrong Answer
time: 0ms
memory: 3624kb
input:
1
output:
impossible
result:
wrong output format Expected integer, but "impossible" found