#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std; int read()
{
int x=,f=;char ch=getchar();
while(ch<'' || ch>'')
{
if(ch=='-') f=-;
ch=getchar();
}
while(ch>='' && ch<='')
{
x=x*+ch-'';
ch=getchar();
}
return x*f;
} struct node
{
int a,b;
}f[]; bool cmp(node x,node y)
{
return x.a*x.b<y.a*y.b;
} int n,kinga,kingb,ans[],add[],sum[];
int i,k; void cheng(int x)
{
memset(add,,sizeof(add));
int j;
for(j=;j<=ans[];j++)
{
ans[j]*=x;
add[j+]+=ans[j]/;
ans[j]%=;
}
for(j=;j<=ans[]+;j++)//max 1000
{
ans[j]+=add[j];
ans[j+]+=ans[j]/;
ans[j]%=;
if(ans[j]!=) ans[]=max(ans[],j);
}
return ;
} void chu(int x)
{
int j;
memset(add,,sizeof(add));
int q=;
for(j=ans[];j>=;j--)
{
q*=;
q+=ans[j];
add[j]=q/x;
if(add[]== && add[j]!=)
{
add[]=j;
}
q%=x;
}
return ;
} bool my_max()
{
if(sum[]>add[]) return ;
if(sum[]<add[]) return ;
int j;
for(j=add[];j>=;j--)
{
if(add[j]<sum[j]) return ;
if(add[j]>sum[j]) return ;
}
return ;
} void my_ans()
{
int j;
memset(sum,,sizeof(sum));
for(j=add[];j>=;j--)
sum[j]=add[j];
return ;
} int main()
{
n=read();
f[].a=read(); f[].b=read();
for(i=;i<=n;i++)
{
f[i].a=read();
f[i].b=read();
}
sort(f+,f+n+,cmp);
ans[]=ans[]=;
for(i=;i<=n;i++)
{
//cout<<"*"<<ans[0]<<"*";
cheng(f[i-].a);
chu(f[i].b);
if(my_max())
{
my_ans();
} //for(k=1;k<=ans[0];k++) cout<<add[k];
//cout<<endl; }
for(i=sum[];i>=;i--) printf("%d",sum[i]); return ;
}

国王游戏

最新文章

  1. Linux CentOS中使用SQL*Plus启动和关闭数据库
  2. 百度地图坐标纠偏和转换工具和DLL
  3. Python中文乱码
  4. 用Apache 里面的ab做一个简单的压力测试
  5. 实战案例:DIV嵌套
  6. Redis集群方案介绍
  7. linux read和write函数
  8. asp.net C#母版页和内容页事件排版载入顺序生命周期
  9. react 学习之十月之思
  10. 防止apche列出目录以及下载文件
  11. linux下 oracle常用命令
  12. 列求key出现的频率
  13. Javascript Sting(字符串)对象
  14. MIPS中有关于分支指令及跳转寻址
  15. C语言作业第二次总结
  16. 安装插件出现eclipse An internal error occurred during: &quot;Installing Software&quot;. xxxxxxxxx
  17. [LeetCode] Design Circular Queue 设计环形队列
  18. cf934C. A Twisty Movement(思维题)
  19. codeforces 632C The Smallest String Concatenation
  20. Cookie深度解析

热门文章

  1. FPGA编程—组合逻辑编码器等verilog实现
  2. 【转载】Ubuntu安装之,硬盘分区
  3. Entity Framework 5中遇到的 mysql tinyint(1) 转换为 bool 的问题 (我用的是VS2013中的EF5版本)
  4. [Artoolkit] Marker of nftSimple
  5. 采用镜像的方法安装python第三方库
  6. arthas使用分享
  7. 企业应用打包的时候 修改ipa包的bundle identifier
  8. Spark2 Random Forests 随机森林
  9. time时间模块
  10. 使用 git log、git diff 命令时出现 ESC[33 和 ESC[m 乱码的解决办法