跳到正文

个人记录

「NLOI Round1」白鸟过河滩

qeyp约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年3月29日
收录
2026年6月20日
更新
2026年11月18日
篇幅
约 1 分钟

版本

  1. v1当前

题目等价于求 ax,by,cz\frac{a}{x},\frac{b}{y},\frac{c}{z} 中的最大值,又因为 t1t2≤s1s2\frac{t1}{t2}\leq\frac{s1}{s2} 当且仅当 t1×s2≤s1×t2t1\times s2\leq s1\times t2 ,即:

  • 若一组是最好的,则 b×x≤c×yb\times x\leq c\times y 且 a×z≤c×xa\times z\leq c\times x 。

  • 否则,若二组是最好的,则 c×y≤b×zc\times y\leq b\times z 。

  • 若均不满足,则三组是最好的。

另外本题卡精度,用 double 会拿到 8585 分。

std如下:

C++
#include <bits/stdc++.h>
using namespace std;

int main(){
	int t;cin>>t;
	while(t--){
		long long a,b,c,x,y,z;
		cin>>a>>b>>c>>x>>y>>z;
		if(a*y>=b*x && a*z>=c*x){
			cout<<"1\n";
		}else if(b*z>=c*y){
			cout<<"2\n";
		}else{
			cout<<"3\n";
		}
	}
	return 0;
}
原文