思路
二分形式
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1e5+10;
int n,k;
int h[N],w[N];
bool check(int u)
{
int cnt=0;
for(int i=0;i<n;i++)
cnt+=(h[i]/u)*(w[i]/u);//每块蛋糕按照当前宽度可以分多少个正方形
if(cnt>=k) return true;
else return false;
}
int main()
{
cin>>n>>k;
for(int i=0;i<n;i++) cin>>h[i]>>w[i];
int l=1,r=1e5;
while(l<r)
{
int mid=l+r+1>>1;
if(check(mid)) l=mid;
else r=mid-1;
}
cout<<l<<endl;
return 0;
}