开始 2024-08-20 08:00:00

8.19-8.24集训第二天

结束 2024-08-25 00:00:00
Contest is over.
当前 2024-12-22 19:28:00

D题

include

include

include

include

include

include

include

using namespace std; int sum[50000],ans[50000],t[50000];

int n; struct node{

int l,r,lr;

}pp[1009]; bool cmp(node x,node y){

if(x.lr!=y.lr) return x.lr<y.lr;
return x.r<y.r;

} void cheng(int x){

for(int i=1;i<=sum[0];i++){
    sum[i]*=x;

}

int i;
for(i=1;i<=sum[0];i++){
    sum[i+1]+=sum[i]/10;
    sum[i]%=10;	
    if(i==sum[0] && sum[sum[0]+1]!=0) sum[0]++;	 
}

} bool judge(){

for(int i=1;i<=t[0];i++){	_ 
    if(t[i]!=ans[i]){
        return t[i]>ans[i];	 
    }
}

} void solve(int x){

int num=0,i=sum[0]+1,s=0;
memset(t,0,sizeof(t));
while(num<x){
    --i;
    num=num*10+sum[i];
}
t[0]=i;	
for(;i>=1;i--){
    t[++s]=num/x;  	 
    num=num%x*10+sum[i-1];	
}
if(t[0]>ans[0] || t[0]==ans[0] && judge()){
    for(int i=0;i<=t[0];i++)
    ans[i]=t[i];
}

} int main(){

scanf("%d",&n);
for(int i=0;i<=n;i++){
    scanf("%d%d",&pp[i].l,&pp[i].r);
    pp[i].lr=pp[i].l*pp[i].r;
}
sum[1]=pp[0].l;/
sum[0]=1;
ans[1]=0;
ans[0]=1;
sort(pp+1,pp+n+1,cmp);
for(int i=1;i<=n;i++){
    cheng(pp[i].l);
    solve(pp[i].lr);
    
}
for(int i=1;i<=ans[0];i++)
i<ans[0]?printf("%d",ans[i]):printf("%d\n",ans[i]);
return 0;

}


chenxi1314  •  4个月前

比赛已结束。