跳到正文

个人记录

代码

_Ascent_约 2 分钟
原文

这是 2026年3月28日 存档的第 3 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

收录
2026年3月14日
更新
2026年7月8日
篇幅
约 2 分钟

版本

  1. v6当前
  2. v5
  3. v4
  4. v3
更早的 2 个版本
  1. v2
  2. v1

#include<bits/stdc++.h> using namespace std; struct node{ int a,b; }m[1005]; bool cmp(node x,node y){return x.ax.b<y.ay.b;} int n,pro[10005],lenp=1,ans[10005],lena=1,tmp[10005]; void mul(int x){ int car=0; for(int i=0;i<lenp;i++){ car+=pro[i]x; pro[i]=car%10; car/=10; } while(car){ pro[lenp++]=car%10; car/=10; } } void div(int x){ memset(tmp,0,sizeof(tmp)); int car=0; for(int i=lenp-1;i>=0;i—){ car=car10+pro[i]; tmp[i]=car/x; car%=x; } } void update(){ int lentmp=lenp; while(lentmp>1&&tmp[lentmp-1]==0)lentmp—; if(lentmp>lena){ lena=lentmp; memcpy(ans,tmp,sizeof(tmp)); return; } if(lentmp<lena)return; for(int i=lentmp-1;i>=0;i—){ if(tmp[i]>ans[i]){ memcpy(ans,tmp,sizeof(tmp)); lena=lentmp; return; } if(tmp[i]<ans[i])return; } } int main(){ cin>>n; for(int i=0;i<=n;i++){ cin>>m[i].a>>m[i].b; } sort(m+1,m+n+1,cmp); pro[0]=m[0].a; for(int i=1;i<=n;i++){ div(m[i].b); update(); mul(m[i].a); } for(int i=lena-1;i>=0;i—){ cout<<ans[i]; } return 0; }