搞了半天才发现TMD是个模拟
#include <bits/stdc++.h>
using namespace std;
#define int long long
int x,y,p,q,ans;
signed main() {
int n;
cin>>p>>q>>n;
ans=1e+9;
for(int i=1;i<=n;i++) {
cin>>x>>y;
int v1=0,v2=0,tmp=0,u=p,v=q;
while(v1<x || v2<y) {
v1+=++u;
v2+=++v;
++tmp;
}
ans=min(ans,tmp);
}
cout<<ans<<endl;
}