标签:scanf eof n+1 print http ref ++ red href
bool cmp(node x,node y)
{
int l=a[1].l;
int k1=max(l/x.r,l*x.l/y.r);
int k2=max(l/y.r,l*y.l/x.r);
if(k1<=k2) return 1;
return 0;
}
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
struct bignum
{
int a[100000],n;
bignum ()
{
n=0;
memset(a,0,sizeof(a));
}
bignum (int x)
{
n=0;
memset(a,0,sizeof(a));
while(x)
{
a[++n]=x%10;
x/=10;
}
}
void print()
{
for(int i=n;i>=1;--i)
printf("%d",a[i]);
printf("\n");
}
};
bignum operator * (const bignum &x,int y)
{
bignum c=x;
for(int i=1;i<=c.n;++i)
c.a[i]*=y;
for(int i=1;i<=c.n;++i)
{
if(c.a[i]>=10)
{
c.a[i+1]+=c.a[i]/10;
c.a[i]%=10;
}
if(i==c.n&&c.a[i+1]!=0) c.n++;
}
return c;
}
bignum operator / (const bignum &x,int y)
{
bignum c;
c.n=x.n;
int n=c.n;
int k=0,tmp=0;
for(int i=n;i>=1;--i)
{
tmp=k*10+x.a[i];
c.a[n--]=tmp/y;
k=tmp%y;
}
while(c.a[c.n]==0&&c.n>0) c.n--;
if(c.n==0) c.n++;
return c;
}
bool operator < (const bignum &x,const bignum &y)
{
if(x.n!=y.n) return x.n<y.n;
for(int i=x.n;i>=1;--i)
if(x.a[i]!=y.a[i]) return x.a[i]<y.a[i];
}
const int N=11000;
struct node
{
int l;
int r;
}e[N];
bool cmp(node x,node y)
{
return x.l*x.r<y.l*y.r;
}/*
bool cmp(node x,node y)
{
int l=e[1].l,r=e[1].r;
int k1=max(l/x.r,l*x.l/y.r);
int k2=max(l/y.r,l*y.l/x.r);
if(k1<=k2) return 1;
return 0;
}*/
int main()
{
//freopen("2.in","r",stdin);
int n;
scanf("%d",&n);
++n;
for(int i=1;i<=n;++i)
scanf("%d%d",&e[i].l,&e[i].r);
sort(e+2,e+n+1,cmp);
bignum ans(e[1].l),anss(0);
int ans2=e[1].l,anss2=0;
for(int i=2;i<=n;++i)
{
anss=max(anss,ans/e[i].r);
anss2=max(anss2,ans2/e[i].r);
ans=ans*e[i].l;
ans2=ans2*e[i].l;
}
//printf("%d",anss);
anss.print();
return 0;
}
标签:scanf eof n+1 print http ref ++ red href
原文地址:https://www.cnblogs.com/wxyww/p/9489586.html