高精度很折磨心态…
#include <iostream>
#include <cstring>
#include <vector>
#include <utility>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
const int N = 1e5;
pii arr[N];
bool cmp(pii a, pii b){
return a.first < b.first;
}
bool larger(vector<int> &a, vector<int> &b){
int len_a = a.size(), len_b = b.size();
if(len_a != len_b) return len_a > len_b;
else{
for(int i = len_a - 1; i >= 0; i--)
if(a[i] != b[i]) return a[i] > b[i];
}
return false;
}
bool equal(vector<int> &a, vector<int> &b){
int len_a = a.size(), len_b = b.size();
if(len_a != len_b) return false;
else{
for(int i = len_a - 1; i >= 0; i--)
if(a[i] != b[i]) return false;
}
return true;
}
vector<int> mul_Axb(vector<int> &a, int b){
vector<int> c;
int len_a = a.size(), carry = 0, pro;
for(int i = 0; i < len_a; i++){
pro = a[i] * b + carry;
c.push_back(pro % 10);
carry = pro / 10;
}
while(carry){
c.push_back(carry % 10);
carry /= 10;
}
while(c.size() > 1 && c.back() == 0) c.pop_back();
return c;
}
// A / b = C ... r, A >= 0, b > 0
vector<int> div_A_b(vector<int> &a, int b){
vector<int> c;
int len_a = a.size(), dividend, r;
for(int i = len_a - 1; i >= 0; i--){
dividend = r * 10 + a[i];
c.push_back(dividend / b);
r = dividend % b;
}
reverse(c.begin(), c.end());
while(c.size() > 1 && c.back() == 0) c.pop_back();
return c;
}
// 将数字x转为逆序存储的数组
void to_vec(int x, vector<int>& c){
if (x == 0) c.push_back(0);
while (x > 0) {
c.push_back(x % 10);
x /= 10;
}
}
int main(){
int n, x, l ,r;
cin >> n;
for(int i = 0; i <= n; i++){
cin >> l >> r;
arr[i] = make_pair(l * r, l);
}
sort(arr + 1, arr + n + 1, cmp);
vector<int> pre_mul(1);
pre_mul = mul_Axb(pre_mul, arr[0].second);
vector<int> res(0), ans(0);
for(int i = 1; i <= n; i++){
res = div_A_b(pre_mul, arr[i].first/arr[i].second);
if(larger(res, ans)) ans = res;
pre_mul = mul_Axb(pre_mul, arr[i].second);
}
for(int i = ans.size() - 1; i >= 0; i--){
cout << ans[i];
}
}