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的倍数 ...
随机推荐
- T1164 统计数字 codevs
http://codevs.cn/problem/1164/ 题目描述 Description [问题描述]某次科研调查时得到了n个自然数,每个数均不超过1500000000(1.5*109).已知不 ...
- jmeter - DBC Request之Query Type
工作中遇到这样一个问题: 需要准备10W条测试数据,利用jmeter中的JDBC Request向数据库中批量插入这些数据(只要主键不重复就可以,利用函数助手中的Random将主键的ID末尾五位数随机 ...
- springboot mybatis 项目框架源码 shiro 集成代码生成器 ehcache缓存
1.代码生成器: [正反双向](单表.主表.明细表.树形表,快速开发利器)freemaker模版技术 ,0个代码不用写,生成完整的一个模块,带页面.建表sql脚本.处理类.service等完整模块2. ...
- JNI——访问数组
JNI在处理基本类型数组和对象数组上面是不同的.对象数组里面是一些指向对象实例或者其它数组的引用. 因为速度的原因,先通过GetXXXArrayElements函数把简单类型的数组转化成本地类型的数组 ...
- 机器学习技法总结(六)Decision Tree Hypothesis
这里先再次提出我们利用aggregation获取更好性能的Hypothesis G所涉及的方法:blending,就是在得到g_set之后进行融合:learning呢?就是在线online的获取g并融 ...
- POJ训练计划1035_Spell checker(串处理/暴力)
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 18418 Accepted: 6759 De ...
- Struts拦截器(转)
xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC &qu ...
- hdu 3746 Cyclic Nacklace (KMP求最小循环节)
//len-next[len]为最小循环节的长度 # include <stdio.h> # include <algorithm> # include <string. ...
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成物理查询计划
淘宝数据库OceanBase SQL编译器部分 源码阅读--生成物理查询计划 SQL编译解析三部曲分为:构建语法树,制定逻辑计划,生成物理执行计划.前两个步骤请参见我的博客<<淘宝数据库O ...
- 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成逻辑计划
body, td { font-family: tahoma; font-size: 10pt; } 淘宝数据库OceanBase SQL编译器部分 源码阅读--生成逻辑计划 SQL编译解析三部曲分为 ...