noip2012国王游戏
来源:互联网 发布:dnf客户端深度优化 编辑:程序博客网 时间:2024/04/29 06:45
program tt;var ans,c,d:array[1..5000]of integer; a,b:array[0..1000]of longint; t,p,x,i,j,n,lc,ld,lans:longint;procedure qsort(x,y:longint);var i,j,mid,t:longint;begin i:=x;j:=y; mid:=a[(x+y) div 2]*b[(x+y) div 2]; repeat while a[i]*b[i]<mid do i:=i+1; while a[j]*b[j]>mid do j:=j-1; if i<=j then begin t:=a[i];a[i]:=a[j];a[j]:=t; t:=b[i];b[i]:=b[j];b[j]:=t; i:=i+1;j:=j-1; end; until i>j; if i<y then qsort(i,y); if x<j then qsort(x,j);end;procedure chu(dd:longint);var len,k,i:longint;begin len:=lc;k:=0; for i:=len downto 1 do begin k:=k*10000+c[i]; d[i]:=k div dd; k:=k mod dd; end; while (d[len]=0)and(len>1) do len:=len-1; ld:=len;end;function compare:boolean;//!!,改为万位同样适用var i:longint;begin for i:=ld downto 1 do begin if d[i]>ans[i] then exit(true); if d[i]<ans[i] then exit(false); end; exit(false);end;procedure print;//!!万位的输出补0var i:longint;begin write(ans[lans]); for i:=lans-1 downto 1 do begin if ans[i]<10 then write(0); if ans[i]<100 then write(0); if ans[i]<1000 then write(0); write(ans[i]); end;end;begin read(n); read(a[0],b[0]); for i:=1 to n do read(a[i],b[i]); qsort(1,n); while a[0]>0 do begin lc:=lc+1; c[lc]:=a[0] mod 10000; a[0]:=a[0] div 10000; end; for i:=1 to n do begin chu(b[i]); if lans<ld then begin lans:=ld; ans:=d; end else if lans=ld then if compare then ans:=d; x:=0; for j:=1 to lc do begin x:=x+c[j]*a[i]; c[j]:=x mod 10000; x:=x div 10000; end; while x>0 do begin lc:=lc+1; c[lc]:=x mod 10000; x:=x div 10000; end; end; print; readln;readln;end.
0 0
- noip2012国王游戏
- NOIP2012 国王游戏
- NOIP2012 国王游戏 题解
- NOIP2012国王游戏
- NOIP2012 国王游戏
- noip2012国王游戏
- noip2012国王游戏
- NOIP2012【国王游戏】
- NOIP2012国王游戏
- NOIP2012国王游戏
- 【NOIP2012】国王游戏
- [P1080][NOIP2012]国王游戏
- [noip2012]国王游戏 题解
- noip2012国王游戏
- 【noip2012】国王游戏
- 国王游戏[NOIP2012]解题报告
- 【NOIP2012提高组】国王游戏
- 【NOIP2012提高组】国王游戏
- 【SICP练习】79 练习2.51
- 【SICP练习】80 练习2.52
- 【SICP练习】81 练习2.53
- HTML5实现Winamp2.9音频播放器插件
- 物联网操作系统的比较
- noip2012国王游戏
- 大O符号
- 高层经理监控项目的十一种思维模式
- Concurrency Simulator
- Breaking Good - CodeForces 507E
- 一个简单的C++顺序表
- mem_fun_ref,mem_fun
- 天声人語 20150222
- Cortex-M3笔记