QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#34308 | #4184. Amusement Arcade | sinbad# | AC ✓ | 2ms | 3696kb | C++17 | 3.9kb | 2022-06-06 22:26:01 | 2022-06-06 22:26:01 |
Judging History
answer
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const multiset<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) {
return vector<decltype(vect(v, m...))>(n, vect(v, m...));
}
using int64 = long long;
using int128 = __int128_t;
using ii = pair<int, int>;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
// mt19937 mrand(random_device{}());
// int rnd(int x) { return mrand() % x; }
mt19937_64 mrand(random_device{}());
int64 rnd(int64 x) { return mrand() % x; }
int lg2(int64 x) { return sizeof(int64) * 8 - 1 - __builtin_clzll(x); }
template <class T> void out(const vector<T>& a) { for (int i = 0; i < SZ(a); ++i) cout << a[i] << " \n"[i + 1 == SZ(a)]; }
template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> void dedup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
void add_mod(int& x, int y) { x += y; if (x >= MOD) x -= MOD; }
void sub_mod(int& x, int y) { x += MOD - y; if (x >= MOD) x -= MOD; }
struct fast_ios {
fast_ios() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << fixed << setprecision(10);
};
} fast_ios_;
int main() {
int64 n;
cin >> n;
if (n == 1) {
cout << 1 << '\n';
return 0;
}
n -= 1;
if (__builtin_popcount(n) > 2) {
cout << "impossible" << '\n';
} else {
cout << (1LL << __builtin_ctzll(n)) + 1 << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3540kb
input:
7
output:
3
result:
ok
Test #2:
score: 0
Accepted
time: 2ms
memory: 3628kb
input:
15
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
19
output:
3
result:
ok
Test #4:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
2049
output:
2049
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
32769
output:
32769
result:
ok
Test #6:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
536870913
output:
536870913
result:
ok
Test #7:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
35184372088833
output:
35184372088833
result:
ok
Test #8:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
2251799813685249
output:
2251799813685249
result:
ok
Test #9:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
576460752303423489
output:
576460752303423489
result:
ok
Test #10:
score: 0
Accepted
time: 1ms
memory: 3560kb
input:
1027
output:
3
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2081
output:
33
result:
ok
Test #12:
score: 0
Accepted
time: 2ms
memory: 3560kb
input:
34393292801
output:
33554433
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
1
output:
1
result:
ok
Test #14:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
281543696187393
output:
68719476737
result:
ok
Test #15:
score: 0
Accepted
time: 2ms
memory: 3492kb
input:
576460752303423491
output:
3
result:
ok
Test #16:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
576460752336977921
output:
33554433
result:
ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3524kb
input:
576461851815051265
output:
1099511627777
result:
ok
Test #18:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
864691128455135233
output:
288230376151711745
result:
ok
Test #19:
score: 0
Accepted
time: 2ms
memory: 3528kb
input:
635
output:
impossible
result:
ok
Test #20:
score: 0
Accepted
time: 1ms
memory: 3632kb
input:
4537995
output:
impossible
result:
ok
Test #21:
score: 0
Accepted
time: 2ms
memory: 3496kb
input:
4795018843
output:
impossible
result:
ok
Test #22:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
5268828738869
output:
impossible
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3556kb
input:
3859135424551273
output:
impossible
result:
ok
Test #24:
score: 0
Accepted
time: 2ms
memory: 3556kb
input:
3
output:
3
result:
ok
Test #25:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
63913510461995523
output:
impossible
result:
ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
341683697045680425
output:
impossible
result:
ok
Test #27:
score: 0
Accepted
time: 2ms
memory: 3608kb
input:
999999999999999999
output:
impossible
result:
ok
Test #28:
score: 0
Accepted
time: 0ms
memory: 3696kb
input:
5
output:
5
result:
ok
Test #29:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
9
output:
9
result:
ok
Test #30:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
11
output:
3
result:
ok
Test #31:
score: 0
Accepted
time: 2ms
memory: 3600kb
input:
13
output:
5
result:
ok
Test #32:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
17
output:
17
result:
ok