39 条题解

  • 1
    @ 2008-10-12 21:47:23

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    秒杀。。

    庆祝AC60题

    。。。。

  • 0
    @ 2018-10-04 10:35:33
    var
    
    n,p1,p2,dian:integer;
    
    a,b:array[1..10000] of integer;
    
    procedure qq;
    
    var
    
    s1,s2:ansistring;
    
    q1,q2,i:integer;
    
    begin
    
    readln(n);
    
    readln(s1);
    
    readln(s2);
    p1:=length(s1);
    
    p2:=length(s2);
    q1:=pos('.',s1);
    
    q2:=pos('.',s2);
    if q10
    
    then begin
    
    dian:=p1-q1; p1:=p1-1;
    
    delete(s1,q1,1);
    
    end;
    if q20
    
    then begin
    
    dian:=dian+p2-q2; p2:=p2-1;
    
    delete(s1,q2,1);
    
    end;
    for i:=1 to p1 do
    
    if s1[i] in ['A'..'G']
    
    then a[p1-i+1]:=ord(s1[i])-55
    
    else a[p1-i+1]:=ord(s1[i])-ord('0');
    for i:=1 to p2 do
    
    if s2[i] in ['A'..'G']
    
    then b[p2-i+1]:=ord(s2[i])-55
    
    else b[p2-i+1]:=ord(s2[i])-ord('0');
    
    end;
    
    procedure main;
    
    var
    
    s:string;
    
    i,j,qq,aa:integer;
    
    c:array[1..10000] of integer;
    
    begin
    
    fillchar(c,sizeof(c),0);
    
    for i:=1 to p1 do
    
    for j:=1 to p2 do
    
    c:=c+b[j]*a[i];
    if c[p1+p2]0
    
    then qq:=p1+p2
    
    else qq:=p1+p2-1;
    for i:=1 to qq do
    
    if c[i]>=n
    
    then begin
    
    c:=c+(c[i] div n);
    
    c[i]:=c[i] mod n;
    
    end;
    if c[qq+1]0
    
    then qq:=qq+1;
    s:='';
    for i:=1 to qq do
    
    if c[i]>=10
    
    then s:=s+chr(c[i]+55)
    
    else s:=s+chr(c[i]+ord('0'));
    if dian>0
    
    then begin
    
    insert('.',s,dian+1);
    
    qq:=qq+1; aa:=0;
    for i:=1 to qq do
    
    if s[i]='0'
    
    then inc(aa)
    
    else break;
    if s[aa+1]='.'
    
    then delete(s,1,aa+1)
    
    else delete(s,1,aa);
    end;
    qq:=length(s);
    
    for i:=qq downto 1 do
    
    if s[i]'0'
    
    then break;
    
    if s[i]='.'
    
    then begin
    
    insert('0',s,1);
    
    i:=i+1;
    
    end;
    for j:=i downto 1do
    
    write(s[j]);
    
    writeln;
    
    end;
    begin
    
    qq;
    
    main;
    
    end.
    
  • 0
    @ 2009-10-26 19:16:37

    编译通过...

    ├ 测试数据 01:答案错误... ├ 标准行输出 63A3...

     ├ 错误行输出 1=41...

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:90 有效耗时:0ms

    悲剧帝求解释 - -

  • 0
    @ 2009-10-24 23:34:57

    都说了是精度计算。。为什么还要删最后的0.。。。

  • 0
    @ 2009-10-21 21:28:39

    数组还是开大的好

  • 0
    @ 2009-09-19 00:13:03

    同问楼下

    我这几天RP到底怎么了……

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案错误...程序输出比正确答案长

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:90 有效耗时:0ms

    var

    s1,s2:ansistring;

    l,i,j,k,d1,d2,l1,l2,x,y:longint;

    a,b,c:array[1..10000]of longint;

    procedure print(i:longint);

    begin

    if i='0')and(s1[i]='0')and(s2[i]0 do begin c[l]:=x mod k;x:=x div k;inc(l);end;dec(l);

    y:=1;while c[y]=0do inc(y);dec(y);

    if d1+d2=d1+d2)then

    for i:=l downto (d1+d2+1)do print(c[i]);

    if (y0 then print(c[i]);

    end;

    end

    else begin

    write('0.');

    for i:=(d1+d2)downto l+1 do write(0);

    for i:=l downto y do if i>0 then print(c[i]);

    end;

    end.

  • 0
    @ 2009-09-18 12:33:43

    哪里错了?

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案错误...程序输出比正确答案长

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:90 有效耗时:0ms

    var

    s1,s2:ansistring;

    k,x,l1,l2,i,j:longint;

    xs:integer;ss:ansistring;

    a,b,c:array[1..1200]of integer;

    begin

    readln(k);

    readln(s1);

    if pos('.',s1)>0 then begin

    xs:=length(s1)-pos('.',s1);

    delete(s1,pos('.',s1),1);

    end;

    readln(s2);

    if pos('.',s2)>0 then begin

    xs:=xs+length(s2)-pos('.',s2);

    delete(s2,pos('.',s2),1);

    end;

    l1:=length(s1);l2:=length(s2);

    for i:=1 to l1 do

    begin

    a[i]:=ord(s1[l1-i+1])-48;

    if a[i]>9 then dec(a[i],7);

    end;

    for i:=1 to l2 do

    begin

    b[i]:=ord(s2[l2-i+1])-48;

    if b[i]>9 then dec(b[i],7);

    end;

    for i:=1 to l1 do

    begin

    x:=0;

    for j:=1 to l2 do

    begin

    x:=x+a[i]*b[j]+c;

    c:=x mod k;

    x:=x div k;

    end;

    j:=i+l2-1;

    while x>0 do

    begin

    inc(j);

    c[j]:=x mod k;

    x:=x div k;

    end;

    end;

    j:=1200;

    while (c[j]=0)and(j>1) do dec(j);

    for i:=j downto xs+1 do

    begin

    if c[i]>9 then ss:=ss+chr(c[i]+55)

    else ss:=ss+chr(c[i]+48);

    end;

    i:=xs;

    while (c[i]=0)and(i>0)do dec(i);

    if i=0 then begin

    writeln(ss);

    halt;

    end;

    ss:=ss+'.';

    for i:=xs downto 1 do

    begin

    if c[i]>9 then ss:=ss+chr(c[i]+55)

    else ss:=ss+chr(c[i]+48);

    end;

    if ss[1]='.'then ss:='0'+ss;

    writeln(ss);

    end.

  • 0
    @ 2009-07-20 18:33:45

    大家注意:一定要开 ansistring!!!!!

  • 0
    @ 2009-07-08 00:29:34

    注意前导0,后导0,小数点的位置。

    可以先输入K=10;

    试试 0.1*0.1 2*3 2*0.3 这几种数据。

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案错误... 

    ├ 标准行输出 0.09...

    ├ 错误行输出 .939...

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    前面的零在没有定位小数点的时候就被我删掉了。。。

  • 0
    @ 2009-05-01 21:59:37

    这个

    a,b,c:array[1..2000]of longint;

    一定要longint不然第一组过不了。

    乘法时在一位上最大可能累计18*18*500这么多,

    超出integer范围。

  • 0
    @ 2009-04-10 18:44:05

    小数点后的最后一位如果是0,就不打了。

    血的教训啊~!

    两遍才AC

  • 0
    @ 2009-04-01 18:11:11

    请问大牛,我哪里错了!

    program gaojingcheng;

    const

    c:array['A'..'I']of integer=(10,11,12,13,14,15,16,17,18);

    w:array[10..18] of char=('A','B','C','D','E','F','G','H','I');

    var

    a,b:array[1..100] of longint;

    d:array[1..200] of longint;

    ch:char;

    i,j,n,k,p,q,t,m,l,v,z:longint;

    f:boolean;

    begin

    readln(k);m:=0;

    while not eoln do

    begin

    read(ch);

    if ch'.' then

    begin

    inc(i);

    if ch in ['A'..'Z'] then a[i]:=c[ch]

    else a[i]:=ord(ch)-48;

    end

    else m:=i;

    end;

    if m0 then m:=i-m;

    readln;

    while not eoln do

    begin

    read(ch);

    if ch'.' then

    begin

    inc(j);

    if ch in ['A'..'Z'] then b[j]:=c[ch]

    else b[j]:=ord(ch)-48;

    end

    else v:=j;

    end;

    if v0 then begin if m0 then m:=m+(j-v) else m:=j-v; end;

    for p:=1 to (i div 2) do

    begin

    t:=a[p];

    a[p]:=a;

    a:=t;

    end;

    for p:=1 to (j div 2) do

    begin

    t:=b[p];b[p]:=b[j-p+1];b[j-p+1]:=t;

    end;

    l:=i+j+1;

    for p:=1 to i+1 do

    for q:=1 to j do

    begin

    d[p+q-1]:=d[p+q-1]+a[p]*b[q];

    d[p+q]:=d[p+q-1] div k +d[p+q];

    d[p+q-1]:=d[p+q-1] mod k;

    end;

    q:=l;

    while d[q]=0 do dec(q);

    for p:=q downto m+1 do

    begin

    inc(z);

    if d[p]>9 then write(w[d[p]])

    else write(d[p]);

    end;

    f:=false;

    for p:=m downto 1 do

    if d[p]0 then f:=true;

    if f then

    begin

    if z=0 then write('0.') else write('.');

    for p:=m downto 1 do

    begin

    if d[p]>9 then write(w[d[p]])

    else write(d[p]);

    end;

    end;

    end.

  • 0
    @ 2009-02-14 08:07:01

    终于搞定了!细节问题很重要!

    1.高精度乘法要细心;

    2.前后多余的零要去掉;

    3.将高精度乘法的进制改为n进制,即将 mod 10,div 10改为 mod n,div n;

    4.小数点的位置要确定,当位数不足时前面要补零;

    5.字符串要用ansistring.

  • 0
    @ 2009-01-19 21:34:07

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    Flag    Accepted

    题号   P1301

    类型(?)   其它

    通过   301人

    提交   1101次

    通过率   27%

    难度   1

    提交 讨论 题解

  • 0
    @ 2009-01-13 13:40:29

    这题我都交了3次才过..

    哎~

  • 0
    @ 2009-01-10 11:10:03

    #include

    using namespace std;

    struct num {

    char n[1000];

    int p;

    };

    void getnum(num&n) {

    char s[501];

    int i,p;

    cin>>s;

    for(i=0;s[i];i++);

    for(n.p=p=0;--i>=0;) if(s[i]=='.') n.p=p; else n.n[p++]=s[i]>r;

    getnum(a);

    getnum(b);

    mul(a,b,r);

    out(a);

    return 0;

    }

    交了2次...第一次2个n.p写成了0...第6个点0.09变成.9...

    面向对象程序:

    #include

    using namespace std;

    struct num {

    char n[1000];

    int p;

    num() {for(int i=0;i>s;

    for(i=0;s[i];i++);

    for(j=0;--i>=0;) if(s[i]=='.') p=j; else n[j++]=s[i]>r;

    a.get();

    b.get();

    a.mul(b,r);

    a.out();

    return 0;

    }

  • 0
    @ 2008-11-21 21:55:59

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    我晕那。。。。调试的时候改ansistring为string忘记改回来了。。。

    小小建议下:最后两头删0时用字符串删方便的多。。。我一开始用的指针,麻烦死我了

  • 0
    @ 2008-11-10 21:53:16

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    秒杀题

  • 0
    @ 2008-10-22 19:42:15

    大牛 我哪错了

    var

    n,p1,p2,dian:integer;

    a,b:array[1..10000] of integer;

    procedure qq;

    var

    s1,s2:ansistring;

    q1,q2,i:integer;

    begin

    readln(n);

    readln(s1);

    readln(s2);

    p1:=length(s1);

    p2:=length(s2);

    q1:=pos('.',s1);

    q2:=pos('.',s2);

    if q10

    then begin

    dian:=p1-q1; p1:=p1-1;

    delete(s1,q1,1);

    end;

    if q20

    then begin

    dian:=dian+p2-q2; p2:=p2-1;

    delete(s1,q2,1);

    end;

    for i:=1 to p1 do

    if s1[i] in ['A'..'G']

    then a[p1-i+1]:=ord(s1[i])-55

    else a[p1-i+1]:=ord(s1[i])-ord('0');

    for i:=1 to p2 do

    if s2[i] in ['A'..'G']

    then b[p2-i+1]:=ord(s2[i])-55

    else b[p2-i+1]:=ord(s2[i])-ord('0');

    end;

    procedure main;

    var

    s:string;

    i,j,qq,aa:integer;

    c:array[1..10000] of integer;

    begin

    fillchar(c,sizeof(c),0);

    for i:=1 to p1 do

    for j:=1 to p2 do

    c:=c+b[j]*a[i];

    if c[p1+p2]0

    then qq:=p1+p2

    else qq:=p1+p2-1;

    for i:=1 to qq do

    if c[i]>=n

    then begin

    c:=c+(c[i] div n);

    c[i]:=c[i] mod n;

    end;

    if c[qq+1]0

    then qq:=qq+1;

    s:='';

    for i:=1 to qq do

    if c[i]>=10

    then s:=s+chr(c[i]+55)

    else s:=s+chr(c[i]+ord('0'));

    if dian>0

    then begin

    insert('.',s,dian+1);

    qq:=qq+1; aa:=0;

    for i:=1 to qq do

    if s[i]='0'

    then inc(aa)

    else break;

    if s[aa+1]='.'

    then delete(s,1,aa+1)

    else delete(s,1,aa);

    end;

    qq:=length(s);

    for i:=qq downto 1 do

    if s[i]'0'

    then break;

    if s[i]='.'

    then begin

    insert('0',s,1);

    i:=i+1;

    end;

    for j:=i downto 1do

    write(s[j]);

    writeln;

    end;

    begin

    qq;

    main;

    end.

  • 0
    @ 2008-10-15 19:34:25

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    秒杀

    一次性AC~~!!

    题目不难,只要存小数位数就是,结果的小数位数就是两个乘数的小数位数之和,注意处理开头和结尾的0

信息

ID
1301
难度
7
分类
高精度 点击显示
标签
(无)
递交数
647
已通过
117
通过率
18%
被复制
3
上传者