zdd6310 @ 2024-04-18 21:48:44
可能是你的 初始值 不够大,本人原来设定的是
by zdd6310 @ 2024-04-18 21:55:24
当然也可能是你被卡精度了,将
ceil(x)
改成 ceil( (long double) x)
即可。
by haozige @ 2024-04-24 19:14:36
@zdd6310 初始值是指哪个
by haozige @ 2024-04-24 19:18:12
能不能帮忙看看
#include<bits/stdc++.h>
using namespace std;
long long l=0,r=1e18;
void problem1(){
long long a,b,n;
cin>>a>>b>>n;
if(n==1){
if(1>r||(n-1)*(a-b)+a<l){
cout<<"0"<<" ";
return;
}
long long x=1;
l=max(l,x);
r=min(r,a);
cout<<"1"<<" ";
return;
}
if((n-2)*(a-b)+a+1>r||(n-1)*(a-b)+a<l){
cout<<"0"<<" ";
return;
}
l=max(l,(n-2)*(a-b)+a+1);
r=min(r,(n-1)*(a-b)+a);
cout<<"1"<<" ";
return;
}
void problem2(){
long long a,b;
cin>>a>>b;
long long dl,dr;
if(l<=a) dl=1;
else dl=ceil(1.0*(l-a)/(a-b))+1;
if(r<=a) dr=1;
else dr=ceil(1.0*(r-a)/(a-b))+1;
if(dl==dr) cout<<dl<<" ";
else cout<<-1<<" ";
}
void slove(){
int n;
cin>>n;
l=0,r=1e18;
for(int i=1;i<=n;i++){
int type;
cin>>type;
if(type==1){
problem1();
}
else{
problem2();
}
}
cout<<endl;
}
int main(){
int t;
cin>>t;
for(int i=1;i<=t;i++){
slove();
}
return 0;
}
by haozige @ 2024-04-24 19:26:51
@zdd6310 没事了,把你说的两个都改过后好了
by haozige @ 2024-04-24 19:27:16
@zdd6310 Thx