[Vijos p1040] High-Precision Multiplication

Source: Internet
Author: User

If noip is not well tested this time, it is because no program has been written since July 29. It's really a tearful fact...

It took me two more nights to resume the code ...)

The first day of TLE. Fortunately, I was smart. When I saw the problem, I said that I had to press the bit to automatically fill out the pressure bit.

The Code style is very strange. I am also drunk when I write 2 kb for my mental retardation questions.

program vijos_p1040;const maxn=10020;var a,b,aa,bb:array[1..maxn] of integer;    c:array[1..2*maxn] of integer;    ma,mb,i,j,t,ca,cb:integer;    ch:char;begin  //assign(input,‘himul.in4‘);reset(input);  //assign(output,‘himul.ou4‘);rewrite(output);  i:=0;  //input num a  while not eoln do    begin      read(ch);      inc(i);      a[i]:=ord(ch)-ord(‘0‘);    end;  ma:=i;  readln;  //reverse num a  for i:=1 to ma div 2 do    begin      t:=a[i];a[i]:=a[ma-i+1];a[ma-i+1]:=t;    end;  //compress num a  for i:=1 to (ma div 2)+1 do    aa[i]:=a[2*i-1]+a[2*i]*10;  //input num b  i:=0;  while not eoln do    begin      read(ch);      inc(i);      b[i]:=ord(ch)-ord(‘0‘);    end;  mb:=i;  //reverse num b  for i:=1 to mb div 2 do    begin      t:=b[i];b[i]:=b[mb-i+1];b[mb-i+1]:=t;    end;  for i:=1 to (mb div 2)+1 do    bb[i]:=b[2*i-1]+b[2*i]*10;  //multi  ca:=ma div 2+1;  cb:=mb div 2+1;  for i:=1 to cb do    begin      for j:=1 to ca do        begin          c[i+j-1]:=c[i+j-1]+aa[j]*bb[i];          if c[i+j-1]>=100 then            begin              c[i+j]:=c[i+j]+c[i+j-1] div 100;              c[i+j-1]:=c[i+j-1] mod 100;            end;        end;    end;  j:=ca+cb+10;  while c[j]=0 do dec(j);  write(c[j]);  for i:=j-1 downto 1 do   begin     if c[i]>=10 then write(c[i]) else write(‘0‘,c[i]);   end;  writeln;  //close(input);close(output);end.
High-Precision Multiplication

 

Test data #0: accepted, time = 0 MS, Mem = 732 kib, score = 25

Test data #1: accepted, time = 15 MS, Mem = 732 kib, score = 25

Test data #2: accepted, time = 15 MS, Mem = 736 kib, score = 25

Test data #3: accepted, time = 608 MS, Mem = 732 kib, score = 25

[Vijos p1040] High-Precision Multiplication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.