提交时间:2024-08-20 22:31:32
运行 ID: 173640
#include<bits/stdc++.h> #define ll long long using namespace std; int n; int len=1; int sum[100001]={0,1}; struct minister{ ll left; ll right; }m[1000001]; bool cmp(minister a,minister b){ return a.left*a.right<b.left*b.right; } void multiplicative(ll x){ for(int i=1;i<=len;i++){ sum[i]*=x; } for(int i=1;i<=len;i++){ sum[i+1]+=sum[i]/10; sum[i]%=10; } len++; while(sum[len]/10){ sum[len+1]=sum[len]/10; sum[len]%=10; len++; } if(sum[len]==0) len--; } void division(){ for(int i=len;i>=1;i--){ sum[i-1]+=(sum[i]%m[n].right*10); sum[i]/=m[n].right; } while(!sum[len]) len--; if(len==0) cout<<"1"<<endl; } int main(){ cin>>n; cin>>m[0].left>>m[0].right; for(int i=1;i<=n;i++) cin>>m[i].left>>m[i].right; sort(m+1,m+1+n,cmp); for(int i=0;i<n;i++){ multiplicative(m[i].left); } division(); for(int i=len;i>=1;i--) cout<<sum[i]; return 0; }