QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54576 | #4184. Amusement Arcade | Username# | WA | 2ms | 3740kb | C++ | 1.2kb | 2022-10-09 19:16:46 | 2022-10-09 19:16:48 |
Judging History
answer
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("popcnt,abm,mmx,avx2")
#endif
#include <bits/stdc++.h>
using namespace std;
#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define rep(i, l, r) for (int i = l; i < r; ++i)
using Long = long long;
using Double = double;
using vi = vector<int>;
template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
is >> p.first >> p.second;
return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
for (auto& x : v) {
is >> x;
}
return is;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
for (auto& x : v) {
os << x << " ";
}
return os;
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
freopen("test.in", "r", stdin);
freopen("test.out", "w", stdout);
#else
#define endl '\n'
#endif
Long n;
cin >> n;
for (Long p = 2 ; p <= n ; p *= 2) {
if (popCnt(n - p - 1) <= 1) {
cout << p + 1 << endl;
return 0;
}
}
cout << "impossible" << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3652kb
input:
7
output:
3
result:
ok
Test #2:
score: 0
Accepted
time: 2ms
memory: 3668kb
input:
15
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 3740kb
input:
19
output:
3
result:
ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
2049
output:
1025
result:
ok
Test #5:
score: 0
Accepted
time: 2ms
memory: 3588kb
input:
32769
output:
16385
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3596kb
input:
536870913
output:
268435457
result:
ok
Test #7:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
35184372088833
output:
17592186044417
result:
ok
Test #8:
score: 0
Accepted
time: 2ms
memory: 3632kb
input:
2251799813685249
output:
1125899906842625
result:
ok
Test #9:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
576460752303423489
output:
288230376151711745
result:
ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
1027
output:
3
result:
ok
Test #11:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
2081
output:
33
result:
ok
Test #12:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
34393292801
output:
33554433
result:
ok
Test #13:
score: -100
Wrong Answer
time: 1ms
memory: 3592kb
input:
1
output:
impossible
result:
wrong output format Expected integer, but "impossible" found