3400: [Usaco2009 mar]cow Frisbee Team Dairy Sand team time Limit:3 Sec Memory limit:128 MB
submit:129 solved:84
[Submit] [Status] [Discuss] After the Description farmer started playing Frisbee, John also intended to let the cows enjoy the frisbee. He's going to build a cow Frisbee team. His N (1≤n≤2000) cows have one Frisbee level index Ri (1≤ri≤100000) per part. John is going to pick 1 or more 1 cows to join his frisbee team. Since John's lucky number is F (1≤f≤1000), he hopes that the sum of all the cows ' frisbee levels is a multiple of the lucky number. Help John figure out how many different ways to team up. Input line 1th enters N and F, and then n lines enter RI. Output Team mode 10^8 The results of the redundancy. Sample INPUT4 5
1
2
8
2Sample Output3hint
There are three kinds of teaming methods (2,3), (3,4), (1,2,4)
Source
Silver
The puzzle: At first, I was thinking about how dfs pruning = = ... Feel yourself water-water da
In fact, is a water DP on the end, remember the last 1 (you can not be a one and then to calculate a method of it)
1/**************************************************************2Problem:34003 User:hansbug4 language:pascal5 result:accepted6Time:260Ms7Memory:23704KB8****************************************************************/9 Ten Constp=100000000; One var A I,j,k,l,m,n:longint; -B:Array[0.. the] ofLongint; -A:Array[0.. the,0.. -] ofLongint; the begin - readln (n,m); - fori:=1 toN Doreadln (B[i]); - fori:=1 toN DoB[i]:=b[i]MoDm; +Fillchar (A,sizeof (a),0); -a[0,0]:=1; + fori:=1 toN Do A forj:=0 toM Do atA[i,j]:= (a[i-1, (J-B[I]+M)MoDm]+a[i-1, j])MoDp; -Writeln (A[n,0]-1); - Readln; - End.
3400: [Usaco2009 mar]cow Frisbee team Dairy Sand Team