QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#623191 | #5721. Dividing by Two | unpleasant_cylinder | AC ✓ | 1ms | 3720kb | C++14 | 1.6kb | 2024-10-09 10:31:52 | 2024-10-09 10:31:52 |
Judging History
answer
#include <bits/stdc++.h>
#include <cstdint>
using namespace std;
// SET TO FALSE BEFORE SUBMITTING
#define DEBUG false
#define print(x) \
do { \
if (DEBUG) { \
cout << "Line " << __LINE__ << ": " #x << " = " << x << endl; \
} \
} while (false)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define ia(n) std::array<int, n>
#define lla(n) std::array<ll, n>
using s8 = int8_t;
using s16 = int16_t;
using s32 = int32_t;
using s64 = int64_t;
using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using vi = std::vector<int>;
using pii = std::pair<int, int>;
using ll = long long;
using vll = std::vector<ll>;
using pll = std::pair<ll, ll>;
u64 get_ops(u64 a, u64 b) {
u64 n = 0;
while (true) {
if (a == b) return n;
if (a < b) return n + b - a;
if (a & 1) ++a;
else a >>= 1;
++n;
}
}
s32 main() {
// DISABLE IF INTERACTIVE
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
u64 a, b;
cin >> a >> b;
cout << get_ops(a, b) << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3648kb
input:
103 27
output:
4
result:
ok single line: '4'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 8
output:
5
result:
ok single line: '5'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
1010 1010
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
536780502 141579856
output:
7384733
result:
ok single line: '7384733'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
108493886 96306036
output:
42059094
result:
ok single line: '42059094'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
376650637 614573517
output:
237922880
result:
ok single line: '237922880'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
359617991 796927336
output:
437309345
result:
ok single line: '437309345'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
414483268 377437212
output:
170195579
result:
ok single line: '170195579'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
264989209 721686150
output:
456696941
result:
ok single line: '456696941'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
535692831 577823164
output:
42130333
result:
ok single line: '42130333'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3704kb
input:
976420008 290057285
output:
45952285
result:
ok single line: '45952285'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
658562524 270258804
output:
105618175
result:
ok single line: '105618175'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
754831094 581446183
output:
204030637
result:
ok single line: '204030637'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
536870913 1
output:
59
result:
ok single line: '59'