Bzoj1655 [usaco 2006 Jan] dollar dayz dairy store

Source: Internet
Author: User
Tags dayz

Simple recursion (recursive statements do not want to be written), but they must be highly precise.

The result is not 1A... Thank you...

To write high precision, suddenly think of Pascal's advanced features, which can define operator, write class, and bring the unit avltree !!!

(Tokens are actually words)

 

 1 /************************************************************** 2     Problem: 1655 3     User: rausen 4     Language: Pascal 5     Result: Accepted 6     Time:56 ms 7     Memory:708 kb 8 ****************************************************************/ 9  10 uses math;11  12 type13   num = array[0..50] of longint;14  15 var16   f : array[0..1500] of num;17   n, k, i, j : longint;18  19 operator + (const a : num; const b : num) c : num;20 var21   i : longint;22  23 begin24   fillchar(c, sizeof(c), 0);25   c[0] := max(a[0], b[0]) + 1;26   for i := 1 to c[0] do begin27     c[i] := c[i] + a[i] + b[i];28     c[i + 1] := c[i] div 10;29     c[i] := c[i] mod 10;30   end;31   while c[c[0]] = 0 do dec(c[0]);32 end;33  34 begin35   readln(n, k);36   f[0, 0] := 1;37   f[0, 1] := 1;38   for i := 1 to k do39     for j := i to n do40       f[j] := f[j] + f[j - i];41   for i := f[j, 0] downto 1 do42     write(f[j, i]);43   writeln;44 end.
View code

(Only sand tea questions will be made recently. Please forgive me>. <)

Bzoj1655 [usaco 2006 Jan] dollar dayz dairy store

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.