社区讨论
萌新刚学OI1ms ,分块求调
P3579[POI 2014] PAN-Solar Panels参与者 4已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @lo1vbch2
- 此快照首次捕获于
- 2023/10/23 03:34 2 年前
- 此快照最后确认于
- 2023/11/03 04:04 2 年前
CPP
#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace Testify{
inline int read(){
int f(1),x(0);
char ch=getchar();
for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1;
for(;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
return f*x;
}
inline void Write(int x){
if(x>9) Write(x/10);
putchar(x%10+48);
}
inline void write(int x){
if(x<0) putchar('-'),x=-x;
Write(x);
putchar('\n');
}
}
using namespace Testify;
int T,a,b,c,d;
int l1,l2,r1,r2;
const int base=31623;
inline bool check(int x){
int A=a/x,C=c/x;
int opa,opb;
if(A*x==a){
opa=A;
}else{
opa=A+1;
}
if(C*x==c){
opb=C;
}
else{
opb=C+1;
}
if(x*opa<=b&&x*opb<=d){
return true;
}
return false;
}
signed main(void){
// freopen("melina.in","r",stdin);
// freopen("melina.out","w",stdout);
T=read();
while(T--){
a=read(),b=read(),c=read(),d=read();
int k1=1,k2=1,Tempestissimo=0;
if(max(b,d)>base){
while(k1<=min(b,base)&&k2<=min(d,base)){
// cerr<<k1<<" "<<k2<<" "<<endl;
l1=(ceil(1.0*(a-1)/k1)),r1=(b/k1),l2=(ceil(1.0*(c-1)/k2)),r2=(d/k2);
// cerr<<l1<<" "<<r1<<" "<<l2<<" "<<r2<<endl;
// int aa=a/base,bb=b/base,cc=c/base,dd=d/base;
if(l2<=r1&&l1<=r2){
Tempestissimo=min(r1,r2);
break;
}
if(l2>r1) k2++;
else if(r2<l1) k1++;
}
}
if(!Tempestissimo){
int r=min(max(c,d),max(a,b));
for(register int i=base;i>=2;i--){
if(check(i)){
Tempestissimo=i;
break;
}
}
}
write(Tempestissimo);
}
return 0;
}
学校OJ没问题?洛谷保龄
回复
共 3 条回复,欢迎继续交流。
正在加载回复...