QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#144672 | #4184. Amusement Arcade | 2468216537 | WA | 1ms | 3572kb | C++17 | 1.0kb | 2023-08-21 17:37:26 | 2023-08-21 17:37:27 |
Judging History
answer
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)x.size())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define per(i,a,n) for(int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using ll = long long;
using PII = pair<int,int>;
using db = double;
using ull = unsigned long long;
mt19937 mrand(random_device{}());
const int N = 100010, M = 18;
int main(){
IOS
ll n;cin >> n;
ll m = n;
if (n <= 3) {
cout << (n + 1) / 2 << endl;
return 0;
}
n--;
int cnt = __builtin_ctzll(n);
n >>= cnt;
ll ans = 0;
if (n == 1){
ans = (1ll << (cnt - 1)) + 1;
}
else{
n--;
int cnt2 = __builtin_ctzll(n);
n >>= cnt2;
if (n != 1){
cout << "impossible\n";
return 0;
}
ans = (1ll << cnt) + 1;
}
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3452kb
input:
7
output:
3
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
15
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
19
output:
3
result:
ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3516kb
input:
2049
output:
1025
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
32769
output:
16385
result:
ok
Test #6:
score: 0
Accepted
time: 1ms
memory: 3456kb
input:
536870913
output:
268435457
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
35184372088833
output:
17592186044417
result:
ok
Test #8:
score: 0
Accepted
time: 1ms
memory: 3496kb
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: 3540kb
input:
1027
output:
3
result:
ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3472kb
input:
2081
output:
33
result:
ok
Test #12:
score: 0
Accepted
time: 1ms
memory: 3492kb
input:
34393292801
output:
33554433
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3564kb
input:
1
output:
1
result:
ok
Test #14:
score: 0
Accepted
time: 1ms
memory: 3472kb
input:
281543696187393
output:
68719476737
result:
ok
Test #15:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
576460752303423491
output:
3
result:
ok
Test #16:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
576460752336977921
output:
33554433
result:
ok
Test #17:
score: 0
Accepted
time: 1ms
memory: 3536kb
input:
576461851815051265
output:
1099511627777
result:
ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3468kb
input:
864691128455135233
output:
288230376151711745
result:
ok
Test #19:
score: 0
Accepted
time: 1ms
memory: 3460kb
input:
635
output:
impossible
result:
ok
Test #20:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
4537995
output:
impossible
result:
ok
Test #21:
score: 0
Accepted
time: 1ms
memory: 3524kb
input:
4795018843
output:
impossible
result:
ok
Test #22:
score: 0
Accepted
time: 1ms
memory: 3528kb
input:
5268828738869
output:
impossible
result:
ok
Test #23:
score: 0
Accepted
time: 1ms
memory: 3540kb
input:
3859135424551273
output:
impossible
result:
ok
Test #24:
score: -100
Wrong Answer
time: 0ms
memory: 3456kb
input:
3
output:
2
result:
wrong answer WA: host sits at an arcade labeled with an even number