题解

23 条题解

  • -4
    @ 2014-12-17 20:29:46

    呵呵

  • -4
    @ 2014-12-17 20:29:32

    sssssssssssssssssssssbbbbbbbbbbbbbbb

    • @ 2017-07-06 15:41:53

      卧槽?????????????

  • -4
    @ 2014-09-28 22:03:09

    program game;
    var a,b,c:array[0..10000]of longint;
    ans,d:array[1..1000000]of longint;
    i,le,n:longint;

    procedure qsort(l,r:longint);
    var j,k,mid,t:longint;
    begin
    j:=l;
    k:=r;
    mid:=c[(l+r) div 2];
    repeat
    while c[j]<mid do inc(j);
    while c[k]>mid do dec(k);
    if j<=k then
    begin
    t:=c[j];
    c[j]:=c[k];
    c[k]:=t;
    t:=a[j];
    a[j]:=a[k];
    a[k]:=t;
    t:=b[j];
    b[j]:=b[k];
    b[k]:=t;
    inc(j);
    dec(k);
    end;
    until j>k;
    if j<r then qsort(j,r);
    if k>l then qsort(l,k);
    end;

    procedure mul(x:longint);
    var t,j:longint;
    begin
    for j:=1 to le do
    ans[j]:=ans[j]*x;
    for j:=1 to le do
    if ans[j]>10 then
    begin
    ans[j+1]:=ans[j+1]+ans[j] div 10;
    ans[j]:=ans[j] mod 10;
    end;
    if ans[le+1]>0 then t:=le+1
    else t:=le;
    while ans[t]>10 do
    begin
    ans[t+1]:=ans[t+1]+ans[t] div 10;
    ans[t]:=ans[t] mod 10;
    inc(t);
    end;
    le:=t;
    end;

    procedure divide(x:longint);
    var j,t:longint;
    begin
    t:=0;
    for j:=le downto 1 do
    begin
    d[le-j+1]:=(t*10+ans[j]) div x;
    t:=(t*10+ans[j]) mod x;
    end;
    end;

    begin
    assign(input,'kinggame.in');
    assign(output,'kinggame.out');
    reset(input);
    rewrite(output);
    readln(n);
    for i:=0 to n do
    readln(a[i],b[i]);
    for i:=1 to n do
    c[i]:=a[i]*b[i];
    qsort(1,n);
    le:=1;
    ans[1]:=1;
    for i:=0 to n-1 do
    mul(a[i]);
    divide(b[n]);
    i:=1;
    while d[i]=0 do inc(i);
    while i<=le do
    begin
    write(d[i]);
    inc(i);
    end;
    close(input);
    close(output);
    end.

信息

ID
1779
难度
7
分类
贪心 | 高精度 点击显示
标签
递交数
5344
已通过
959
通过率
18%
被复制
10
上传者