Files
lanqiao/14lanqiao/test3-2.cpp
2025-03-19 14:03:40 +08:00

27 lines
553 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// lanqiao3510 冶炼金属
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
int mxv = INT_MIN; int miv = INT_MAX;
for(int i = 1; i <= n; i++){
int a, b; cin >> a >> b;
miv = min(miv, a/b);
mxv = max(mxv, a/(b+1)+1);
}
cout << mxv << " " << miv << endl;
return 0;
}
/*
数学优化
通过floor(A/V) = B可以推出 A/V =B,B+1
进而得到B <= A/V < B+1三个表达式同时被A除
得到关于V的不等式即 A/B >= V > A/(B+1)
*/
/* test samples
3
75 3
53 2
59 2
*/