![](https://i-blog.csdnimg.cn/blog_migrate/c2b22a6338014ef949617db293ceff65.png)
0408重写代码:
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int maxx=1000000010,minn=-1;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int a,b;
scanf("%d%d",&a,&b);
maxx = min(maxx,a/b);
minn = max(minn,a/(b+1)+1);
}
cout<<minn<<' '<<maxx<<endl;
return 0;
}
0322重写代码:
#include<algorithm>
#include<iostream>
using namespace std;
int maxx=1000000010,minn=-1;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
int a,b;
scanf("%d%d",&a,&b);
maxx = min(maxx,a/b);
minn = max(minn,a/(b+1)+1);
}
printf("%d %d\n",minn,maxx);
return 0;
}
![](https://i-blog.csdnimg.cn/blog_migrate/7b581488a84af5030d74b361e8f92f76.png)
二分代码1:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int get(int a, int b){
int l=1;r=1e9+1;
while(l<r){
int mid = l+r >>1;
if(a / mid <= b){
r = mid;
}
else l = mid + 1;
}
return l;
}
int main()
{
int n;
scanf("%d",&n);
int minn = 1,maxx = 1e9;
while(n--){
int a,b;
scanf("%d%d",&a,&b);
minn = max(minn,get(a,b));
maxx = min(maxx,get(a,b-1) - 1);
}
cout<<minn<<" "<<maxx<<endl;
return 0;
}
误打误撞代码2:
![](https://i-blog.csdnimg.cn/blog_migrate/dbbc2c1d91b34d3329fb40becb584407.png)
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n;
//设最小是minn,最大是maxx,最大的情况就是除,一个也没浪费
int v[10010];
int x[10010];
int minn = -1;
int maxx = 1000000000;
int main()
{
scanf("%d",&n);
for(int i = 0;i < n; i ++){
scanf("%d%d",&v[i],&x[i]);
maxx = min(v[i]/x[i], maxx);
minn = max(v[i]/(x[i]+1)+1, minn);
}
//cout<<xx<<" "<<vv<<endl;
cout<<minn<<" "<<maxx<<endl;
return 0;
}