好像可以读的懂
C++ 代码
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int maxn = 1005;
int n,a,b;
typedef pair<int, int> pii;
vector<pii> peo;
vector<int> res;
vector<int> maxres;
vector<int> mul(vector<int> v,int a){
vector<int> ret;
int x=0 , k =0 ;
for( int i=0 ; i<res.size() ; i++){
x = res[i] * a+k;
ret.push_back(x%10);
k = x/10;
}
while(k){
ret.push_back(k%10);
k/=10;
}
return ret;
}
vector<int> exp(vector<int> v , int a){
vector<int> ret;
int x=0 , k=0;
for( int i = v.size()-1 ; i>=0 ; i--){
x=10*k+v[i];
if(x/a||ret.size()) ret.push_back(x/a);
k= x%a;
}
return ret;
}
vector<int> cmp(vector<int> a , vector<int> b){
if(a.size() > b.size()) return a;
if(a.size() < b.size()) return b;
for( int i=0 ;i<a.size() ; i++){
if(a[i]>b[i]) return a;
if( a[i] < b[i]) return b;
}
return a;
}
int main(){
cin>>n>>a>>b;
res.push_back(1);
res=mul(res,a);
while(n--){
cin>>a>>b;
pii p(b*a,a);
peo.push_back(p);
}
sort(peo.begin(),peo.end());
for( auto x : peo){
res=mul(res, x.second);
vector<int> temp = exp(res,x.first);
maxres=cmp(maxres, temp);
}
for(auto x:maxres) cout<<x;
cout<<endl;
return 0 ;
}