最多1000个9999相乘,所以会用到高精度
#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n;
struct People{
int a,b;
bool operator <(const People &W)const {
return a*b<W.a*W.b;
}
}people[N];
vector<int> mul(vector<int> a,int b){
int t=0;
vector<int> res;
for(int i=0;i<a.size()||t;i++){
if(i<a.size()) t+=a[i]*b;
res.push_back(t%10);
t/=10;
}
return res;
}
vector<int> div(vector<int> a,int b){
int r=0;
vector<int> res;
for(int i=a.size()-1;i>=0;i--){
r=r*10+a[i];
res.push_back(r/b);
r%=b;
}
reverse(res.begin(),res.end());
while(res.size()>1&&res.back()==0) res.pop_back();
return res;
}
vector<int> max_vec(vector<int> a,vector<int> b){
if(a.size()>b.size()) return a;
if(a.size()<b.size()) return b;
if( vector<int>(a.rbegin(),a.rend())>(vector<int> (b.rbegin(),b.rend()) ) ) return a;
return b;
}
int main(){
cin>>n;
for(int i=0;i<=n;i++){
int a,b;
cin>>a>>b;
people[i]={a,b};
}
sort(people+1,people+n+1);
vector<int> p(1,people[0].a);
vector<int> res(1,0);
for(int i=1;i<=n;i++){
vector<int> t=div(p,people[i].b);
res=max_vec(res,t);
p=mul(p,people[i].a);
}
for(int i=res.size()-1;i>=0;i--) cout<<res[i];
}