QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#864331 | #9859. King of Gamers | Nolearnnodo# | TL | 0ms | 3840kb | C++14 | 1017b | 2025-01-20 14:52:44 | 2025-01-20 14:52:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin>>t;
long long n,ans,a,b,n1,n2,nowa,nowb,left,right,tx,mid;
while(t--){
ans=1;
scanf("%lld %lld %lld",&n,&a,&b);
if(n==1 || a==0){
printf("1\n");
continue;
}
if(a==b){
printf("%lld\n",n);
continue;
}
nowa=1; nowb=1; tx=n-1;
while(1){
left=1,right=tx;
while(left<right){ //先输一些
mid=(left+right)>>1;
if(a*(nowb+mid)>=b*nowa){
right=mid;
}
else{
left=mid+1;
}
}
n1=right;
if(a*(nowb+left)<b*nowa){
break;
}
nowb+=left; tx-=left;
if(tx==0) break;
left=1,right=tx;
while(left<right){
mid=(left+right)>>1;
if(a*(nowb+mid)<b*(nowa+mid)){
right=mid;
}
else{
left=mid+1;
}
}
n2=left;
nowa+=left; nowb+=left; tx-=left;
ans+=left;
if(tx==0) break;
if(n1==1&&n2==1){
ans+=tx/2;
break;
}
}
printf("%lld\n",ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
3 4 3 5 8 7 10 1 1 3
output:
2 5 1
result:
ok 3 number(s): "2 5 1"
Test #2:
score: -100
Time Limit Exceeded
input:
100000 666977257 46322301 444651505 775037696 10955843 81788929 943459623 1 500000071 998998627 85 465525978 998969116 949398518 949398594 999995971 172077240 464085681 406334061 103283849 270889374 919331712 241327022 645922817 892656218 7 576716801 999547883 26 713779916 998450133 108731744 108731...