• BZOJ1655 [Usaco2006 Jan] Dollar Dayz 奶牛商店


    简单递推(递推式真不想写了),但是要高精加。

    结果没有1A。。。蒟蒻啊。。。

    要写高精加,突然想到Pascal的高深之处,既可以定义operator,还可以写class,而且自带unit AVLtree!!!

    (↑其实就是凑字数的)

     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 type
    13   num = array[0..50] of longint;
    14  
    15 var
    16   f : array[0..1500] of num;
    17   n, k, i, j : longint;
    18  
    19 operator + (const a : num; const b : num) c : num;
    20 var
    21   i : longint;
    22  
    23 begin
    24   fillchar(c, sizeof(c), 0);
    25   c[0] := max(a[0], b[0]) + 1;
    26   for i := 1 to c[0] do begin
    27     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 begin
    35   readln(n, k);
    36   f[0, 0] := 1;
    37   f[0, 1] := 1;
    38   for i := 1 to k do
    39     for j := i to n do
    40       f[j] := f[j] + f[j - i];
    41   for i := f[j, 0] downto 1 do
    42     write(f[j, i]);
    43   writeln;
    44 end.
    View Code

    (最近只会做沙茶题,请见谅>.<)

    By Xs酱~ 转载请说明 博客地址:http://www.cnblogs.com/rausen
  • 相关阅读:
    翻硬币
    排队打水问题
    连续邮资问题
    Linux-AWK命令
    SpringInAction第五章总结 使用配置属性
    SpringInAction 第四章笔记 保护Spring
    SpringInAction第三章笔记 --使用数据
    SpringInAction第二章笔记
    SpringInAction第一章笔记
    SpringBoot启动任务
  • 原文地址:https://www.cnblogs.com/rausen/p/4023259.html
Copyright © 2020-2023  润新知