P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team
题目描述
After Farmer Don took up Frisbee, Farmer John wanted to join in the fun. He wants to form a Frisbee team from his N cows (1 <= N <= 2,000) conveniently numbered 1..N. The cows have been practicing flipping the discs around, and each cow i has a rating R_i (1 <= R_i <= 100,000) denoting her skill playing Frisbee. FJ can form a team by choosing one or more of his cows.
However, because FJ needs to be very selective when forming Frisbee teams, he has added an additional constraint. Since his favorite number is F (1 <= F <= 1,000), he will only accept a team if the sum of the ratings of each cow in the team is exactly divisible by F.
Help FJ find out how many different teams he can choose. Since this number can be very large, output the answer modulo 100,000,000.
Note: about 50% of the test data will have N <= 19.
农夫顿因开始玩飞盘之后,约翰也打算让奶牛们享受飞盘的乐趣.他要组建一只奶牛飞盘
队.他的N(1≤N≤2000)只奶牛,每只部有一个飞盘水准指数Ri(1≤Ri≤100000).约翰要选出1只或多于1只奶牛来参加他的飞盘队.由于约翰的幸运数字是F(1≤F≤1000),他希望所有奶牛的飞盘水准指数之和是幸运数字的倍数.
帮约翰算算一共有多少种组队方式.
输入输出格式
输入格式:
Line 1: Two space-separated integers: N and F
- Lines 2..N+1: Line i+1 contains a single integer: R_i
输出格式:
- Line 1: A single integer representing the number of teams FJ can choose, modulo 100,000,000.
输入输出样例
4 5
1
2
8
2
3
说明
FJ has four cows whose ratings are 1, 2, 8, and 2. He will only accept a team whose rating sum is a multiple of 5.
FJ can pair the 8 and either of the 2's (8 + 2 = 10), or he can use both 2's and the 1 (2 + 2 + 1 = 5).
【题目大意】
从n个数中选出几个数使他成为f的倍数的方案数。
【思路】
动态规划...
dp[i][j]表示前i个牛,选择的牛的数的和%f==j的方案数。不是很懂转移方程+r[i]不是-r[i]
【code】
#include<iostream>
#include<cstdio>
using namespace std;
#define mod 100000000
int n,f;
int r[],dp[][];
int main()
{
scanf("%d%d",&n,&f);
for(int i=;i<=n;i++)
scanf("%d",&r[i]);
dp[][]=;
for(int i=;i<=n;i++)
for(int j=;j<=f;j++)
{
dp[i][j]+=dp[i-][j]+dp[i-][(j+r[i])%f];
dp[i][j]%=mod;
}
printf("%d\n",dp[n][f]%mod);
return ;
}
P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team的更多相关文章
- luogu P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team
题目背景 老唐最近迷上了飞盘,约翰想和他一起玩,于是打算从他家的N头奶牛中选出一支队伍. 每只奶牛的能力为整数,第i头奶牛的能力为R i .飞盘队的队员数量不能少于 1.大于N.一 支队伍的总能力就是 ...
- 牛飞盘队Cow Frisbee Team
老唐最近迷上了飞盘,约翰想和他一起玩,于是打算从他家的N头奶牛中选出一支队伍. 每只奶牛的能力为整数,第i头奶牛的能力为R i .飞盘队的队员数量不能少于 .大于N. 一支队伍的总能力就是所有队员能力 ...
- USACO Cow Frisbee Team
洛谷 P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team 洛谷传送门 JDOJ 2632: USACO 2009 Mar Silver 2.Cow Frisbee Team ...
- BZOJ3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队
3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 89 Solve ...
- 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队
3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 129 Solv ...
- BZOJ 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 动态规划
3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=34 ...
- bzoj:3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队
Description 农夫顿因开始玩飞盘之后,约翰也打算让奶牛们享受飞盘的乐趣.他要组建一只奶牛飞盘 队.他的N(1≤N≤2000)只奶牛,每只部有一个飞盘水准指数Ri(1≤Ri≤10000 ...
- 【BZOJ】3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队(dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=3400 既然是倍数我们转换成mod.. 设状态f[i][j]表示前i头牛modj的方案 那么答案显然是 ...
- BZOJ 3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队:dp【和为f的倍数】
题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1375 题意: 给你n个数,你可以从中选任意多个,但不能不选.问你所选数字之和为f的倍数 ...
随机推荐
- UItableView 所有内容保存为图片
将所有的UITableView保存为图片,因为UITableView只能保存显示当前,所以,就单个保存后,合并为一张图片 代码如下: -(IBAction)savePic:(id)sender { / ...
- Go -- 中结构体与字节数组能相互转化
编码时如下,假设默认你的结构体为data func Encode(data interface{}) ([]byte, error) { buf := bytes.NewBuffer(nil) enc ...
- lua 异常 错误处理 pcall
lua 错误处理 匿名函数 if pcall(function () local s=object.data[1]['type'] end) then return object.data[1]['t ...
- 一句话说清楚啥是delegate
所谓托付就是类对象调用.托付对象代表随意实现该托付的类的对象.
- 性能測试JMeter趟的坑之JMeter的bug:TPS周期性波动问题
先说下问题: 我在做性能測试时,使用JMeter搞了100个并发,以100TPS的压力压測十分钟,但压力一直出现波动.并且出现波动时JMeter十分卡,例如以下图: 周期性TPS波动 各种猜測: 所以 ...
- 最小公倍数(Least Common Multiple)
最小公倍数=两个数的乘积/两个数的最大公约数. 接上篇求最大公约数方法,最小公倍数的代码例如以下: public class LCM { //最小公倍数=两数乘积/最大公约数 public stati ...
- 服务器----1U、2U、3U、4U
U是一种表示服务器外部尺寸的单位,是unit的缩略语,详细的尺寸由作为业界团体的美国电子工业协会(EIA)所决定. 之所以要规定服务器的尺寸,是为了使服务器保持适当的尺寸以便放在铁质或铝质的机架上.机 ...
- v-on指令
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- JAVA BigDecimal 高精度运算
文章参考一位博友,由于时间太久忘了链接,见谅! public class BigDecimalUtils { private static final int DIV_SCALE = 10;// 除法 ...
- MTK 手机芯片 2014 Roadmap
注:其中 A53 架构的是 64 位处理器. MT6733 魅蓝 MT6752 魅族 note 联通/移动版 MT6595 魅族 MX4