95行,沉默ing……
#include<bits/stdc++.h>
using namespace std;
struct node{
int l,r;
node(){}
node(int x,int y):l(x),r(y){}
bool operator <(const node &x)const{
return l*r<x.l*x.r;
}
}a[4005];
struct data{
int s[4005],len;
data(){
memset(s,0,sizeof(s));
len=1;
}
data(int x){
memset(s,0,sizeof(s));
len=1;
int i=0;
while(x){
s[++i]=x%10;
x/=10;
}
len=i;
}
};
data operator *(const data &a,const int &b){
data c;
c.len=a.len;
for(int i=1;i<=c.len;i++){
c.s[i]+=a.s[i]*b;
c.s[i+1]+=c.s[i]/10;
c.s[i]%=10;
}
if(c.s[c.len+1]){
int x=c.s[c.len+1],len=c.len;
while(x){
c.s[++len]=x%10;
x/=10;
}
c.len=len;
}
return c;
}
data operator/(const data &a,const int &b){
data c;
c.len=a.len;
int x=0;
for(int i=c.len;i>=1;i--){
x=x*10+a.s[i];
c.s[i]=x/b;
x%=b;
}
while(!c.s[c.len]&&c.len>1) c.len--;
return c;
}
bool operator <(const data &a,const data &b){
if(a.len==b.len){
for(int i=a.len;a.s[i]==b.s[i]&&i>1;i--){
if(i>=1){
return a.s[i]<b.s[i];
}
else return false;
}
}
else return a.len<b.len;
}
void p(const data &a){
for(int i=a.len;i>=1;i--){
cout<<a.s[i];
}
}
int n,x,y;
data cnt;
int main(){
cin>>n;
for(int i=0;i<=n;i++){
cin>>x>>y;
a[i]=node(x,y);
}
sort(a+1,a+n+1);
data k(1);
for(int i=1;i<=n;i++){
if(a[i-1].l==0){
break;
}
k=k*a[i-1].l;
data temp;
temp=k/a[i].r;
if(cnt<temp) cnt=temp;
}
p(cnt);
return 0;
}
```