QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#69853 | #5115. Clone Ranran | magicduck# | WA | 2ms | 3272kb | C++14 | 1.3kb | 2023-01-02 13:43:06 | 2023-01-02 13:43:10 |
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(b), read(a), 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: 0
Wrong Answer
time: 2ms
memory: 3272kb
input:
5 1 1 1 2 3 3 9 9 9 3 26 47 1064 822 1048576
output:
1 6 45 88 17504
result:
wrong answer 2nd numbers differ - expected: '7', found: '6'