P3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队

太水了,背包DP。

(转载请注明出处:http://www.cnblogs.com/Kalenda/)

 1 const maxn=100000000;
 2 var n,f,i,j,ans,t,tt:longint;
 3 q:array[0..3000] of longint;
 4 a:array[0..3000,0..2000] of longint;
 5 begin
 6   readln(n,f);
 7   for i:=1 to n do
 8     begin
 9       readln(q[i]);
10       q[i]:=q[i] mod f;
11     end;
12   a[0,0]:=1;
13   for i:=1 to n do
14     for j:=0 to f do
15       a[i,j]:=(a[i-1,(j-q[i]+f) mod f]+a[i-1,j]) mod maxn;
16   writeln(a[n,0]-1);
17 end.
posted @ 2015-09-18 11:49  LovelyMonster丶  阅读(238)  评论(0编辑  收藏  举报