题目描述

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.

输入输出样例

输入样例#1:

4 5
1
2
8
2
输出样例#1:

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的更多相关文章

  1. luogu P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team

    题目背景 老唐最近迷上了飞盘,约翰想和他一起玩,于是打算从他家的N头奶牛中选出一支队伍. 每只奶牛的能力为整数,第i头奶牛的能力为R i .飞盘队的队员数量不能少于 1.大于N.一 支队伍的总能力就是 ...

  2. 牛飞盘队Cow Frisbee Team

    老唐最近迷上了飞盘,约翰想和他一起玩,于是打算从他家的N头奶牛中选出一支队伍. 每只奶牛的能力为整数,第i头奶牛的能力为R i .飞盘队的队员数量不能少于 .大于N. 一支队伍的总能力就是所有队员能力 ...

  3. USACO Cow Frisbee Team

    洛谷 P2946 [USACO09MAR]牛飞盘队Cow Frisbee Team 洛谷传送门 JDOJ 2632: USACO 2009 Mar Silver 2.Cow Frisbee Team ...

  4. BZOJ3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队

    3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 89  Solve ...

  5. 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队

    3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 129  Solv ...

  6. BZOJ 3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 动态规划

    3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队 题目连接: http://www.lydsy.com/JudgeOnline/problem.php?id=34 ...

  7. bzoj:3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队

    Description     农夫顿因开始玩飞盘之后,约翰也打算让奶牛们享受飞盘的乐趣.他要组建一只奶牛飞盘 队.他的N(1≤N≤2000)只奶牛,每只部有一个飞盘水准指数Ri(1≤Ri≤10000 ...

  8. 【BZOJ】3400: [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队(dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=3400 既然是倍数我们转换成mod.. 设状态f[i][j]表示前i头牛modj的方案 那么答案显然是 ...

  9. BZOJ 3400 [Usaco2009 Mar]Cow Frisbee Team 奶牛沙盘队:dp【和为f的倍数】

    题目链接:http://begin.lydsy.com/JudgeOnline/problem.php?id=1375 题意: 给你n个数,你可以从中选任意多个,但不能不选.问你所选数字之和为f的倍数 ...

随机推荐

  1. CF 2018 Battle of Brains GYM 102062 F

    https://codeforces.com/gym/102062/attachments/download/8213/2018-battle-of-brains-en.pdf https://cod ...

  2. Js 中的输出

    document.write()和window.alert() 1.window.document.write(字符串或者是变量名) 作用:它会在body标签内输出内容 说明: window代表当前浏 ...

  3. Centos7 下的防火墙端口配置

    如果外部不能访问,需要查看防火墙以及服务器的端口安全设置. 防火墙的操作 查看所有打开的端口: firewall-cmd --zone=public --list-ports 添加 firewall- ...

  4. Hadoop 连接mysql

    1 mysql数据导入到hdfs数据 hadoop提供了org.apache.hadoop.io.Writable接口来实现简单的高效的可序列化的协议,该类基于DataInput和DataOutput ...

  5. Ubuntu 16.04安装CrossOver容器来安装QQ(终极解决办法,亲测有效)

    说明:此版本的QQ基本完美,但是有个缺点就是历史记录有些会显示乱码! 注意:此方法能完美解决这篇文章http://www.cnblogs.com/EasonJim/p/7118693.html的所有问 ...

  6. DeepFM

    DeepFM integrates the architectures of FM and deep neural networks (DNN). It models low-order featur ...

  7. winform中使用ReportViewer的时候,找不到报表数据面板.

    最近在做winform的报表项目,看人家教程里都有报表数据面板,可我的怎么都找不到,我的是VS2012,最后终于找到,首先必须在报表设计TAB上(选中它),然后选择视图->报表数据

  8. ubuntu 的权限和目录

    / : 根目录 /bin 和 /sbin中放置的是可执行文件   /etc 里面放的是配置文件    /boot 引导 /mnt  是挂载目录 /home   主目录 /dev  设备 /usr li ...

  9. HDU 1040 As Easy As A+B [补]

    今天去老校区找她,不想带电脑了,所以没时间A题了 /*******************************************************************/ As Ea ...

  10. 原生js实现悬浮框滑动动画

    最近在做个人博客想做个相册,鼠标悬浮后出现个div并且鼠标移动到哪个相册,div跟随到哪个相片上. <!DOCTYPE html> <html lang="en" ...