QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#69852 | #5115. Clone Ranran | magicduck# | WA | 567ms | 3340kb | C++14 | 1.3kb | 2023-01-02 13:37:19 | 2023-01-02 13:37:21 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
template <typename T> inline void read(T &F) {
int R = 1; F = 0; char CH = getchar();
for(; !isdigit(CH); CH = getchar()) if(CH == '-') R = -1;
for(; isdigit(CH); CH = getchar()) F = F * 10 + CH - 48;
F *= R;
}
inline void file(string str) {
freopen((str + ".in").c_str(), "r", stdin);
freopen((str + ".out").c_str(), "w", stdout);
}
const int Log = 40;
LL a, b, c, pw[Log];
LL calc(LL x) {
LL ans = 0;
for(int i = 1; i <= 100; i++) {
if(i * b > x) break;
LL lg = (x - i * b) / a;
if(lg >= 31) return 1e18;
ans = max(ans, pw[lg] * i);
}
return ans;
}
int main() {
//file("");
pw[0] = 1;
for(int i = 1; i < Log; i++)
pw[i] = pw[i - 1] * 2;
int T; read(T);
while(T--) {
read(a), read(b), read(c);
LL l = 0, r = c * b, res = 0;
while(l <= r) {
LL mid = (l + r) >> 1;
if(calc(mid) >= c) res = mid, r = mid - 1;
else l = mid + 1;
}
cout << res << '\n';
}
#ifdef _MagicDuck
fprintf(stderr, "# Time: %.3lf s", (double)clock() / CLOCKS_PER_SEC);
#endif
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3336kb
input:
5 1 1 1 2 3 3 9 9 9 3 26 47 1064 822 1048576
output:
1 7 45 44 21860
result:
ok 5 number(s): "1 7 45 44 21860"
Test #2:
score: -100
Wrong Answer
time: 567ms
memory: 3340kb
input:
99500 1000000000 1000000000 1000000000 1000000000 1000000000 999999999 1000000000 1000000000 999999998 1000000000 1000000000 999999997 1000000000 1000000000 999999996 1000000000 1000000000 999999995 1000000000 1000000000 999999994 1000000000 1000000000 999999993 1000000000 1000000000 999999992 10000...
output:
31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 31000000000 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999998 30999999996 30999999996 30999999996 30999999996 30999999996 ...
result:
wrong answer 24501st numbers differ - expected: '1000000000', found: '0'