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