QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#64111 | #5115. Clone Ranran | DaBenZhongXiaSongKuaiDi# | AC ✓ | 686ms | 3568kb | C++20 | 722b | 2022-11-24 09:07:10 | 2022-11-24 09:07:12 |
Judging History
answer
#include <bits/stdc++.h>,
//#define int long long
#define ll long long
#define db double
#define fi first
#define se second
#define pii pair<int,int>
#define vi vector<int>
#define i128 __int128
using namespace std;
int a,b,c;
int check(i128 x) {
i128 pw=1,num=0;
for (i128 o=0;;) {
i128 sheng=x-o;
i128 t=sheng/b;
t=t*pw;
if (t>=c) return 1;
if (pw>c) break ;
pw*=2,o+=a;
}
return 0;
}
void solve() {
scanf("%d %d %d",&a,&b,&c);
i128 l=1,r=1e13; ll ans;
while (l<=r) {
i128 mid=(l+r)>>1;
if (check(mid)) {
ans=mid;
r=mid-1;
} else l=mid+1;
}
cout<<ans<<'\n';
}
int main() {
int T;
scanf("%d",&T);
while (T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3448kb
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: 0
Accepted
time: 686ms
memory: 3568kb
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:
ok 99500 numbers