HDU1723 Distribute Message(dp)
来源:互联网 发布:怎么购买高达模型 知乎 编辑:程序博客网 时间:2024/05/18 08:49
题目;
Distribute Message
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2056 Accepted Submission(s): 1026
Problem Description
The contest’s message distribution is a big thing in prepare. Assuming N students stand in a row, from the row-head start transmit message, each person can transmit message to behind M personals, and how many ways could row-tail get the message?
Input
Input may contain multiple test cases. Each case contains N and M in one line. (0<=M<N<=30)
When N=0 and M=0, terminates the input and this test case is not to be processed.
When N=0 and M=0, terminates the input and this test case is not to be processed.
Output
Output the ways of the Nth student get message.
Sample Input
4 14 20 0
Sample Output
13Hint4 1 : A->B->C->D4 2 : A->B->C->D, A->C->D, A->B->D
Author
威士忌
Source
HZIEE 2007 Programming Contest
Recommend
lcy | We have carefully selected several similar problems for you: 1160 1414 1727 1725 1726
因为要传给后面的m个人,所以后面的每个人加上当前的这种情况,所以递推公式为:
dp[i+j]=dp[i+j]+dp[i]
代码:
#include <cstdio>#include <cstring>#include <cctype>#include <string>#include <set>#include <iostream>#include <stack>#include <map>#include <cmath>#include <queue>#include <vector>#include <algorithm>#define mem(a,b) memset(a,b,sizeof(a))#define inf 0x3f3f3f3f#define mod 1000007#define N 8#define M 12357#define ll long longusing namespace std;int n,m;int dp[35];int solve(int n,int m){memset(dp,0,sizeof(dp));dp[1] = 1;for(int i = 1; i < n; i++)for(int j = 1; j <= m; j++)dp[i+j] += dp[i];return dp[n];}int main(){while(scanf("%d%d",&n,&m)&&(n||m)){printf("%d\n",solve(n,m));}return 0;}
阅读全文
0 0
- HDU1723 Distribute Message(dp)
- hdu1723 Distribute Message
- HDU 1723 Distribute Message(DP)
- HDU 1723--Distribute Message【DP】
- hdu1723基础dp
- hdu 1723 Distribute Message (DP)
- HDU 1723 动态规划(DP) Distribute Message
- HDOJ 1723 Distribute Message(超水DP)
- Distribute Message
- HDU 1723 Distribute Message--DP--(特殊意义)
- hdu 1723 Distribute Message
- HDU 1723-Distribute Message-dp-(有向图路径模型)
- Distribute Message (HDU 1723)
- hdoj1723_Distribute Message(dp)
- PROFIBUS-DP Global Control Message
- 【DP】 Mahmoud and a Message
- hdu 4661 Message Passing(树形dp)
- hdu 4661 Message Passing(树形dp)
- 基于Redis实现分布式锁
- python assert的作用
- JAVA虚拟机系列(十)
- adb shell 相关命令记录
- PostgreSQL中的group_concat使用
- HDU1723 Distribute Message(dp)
- EditText的输入限制类型
- javaScript中的this
- OpenCV相机标定
- 【更新】Aspose.Pdf 7月新版发布 | 附下载
- react-native 遇到的错误
- hdu-2222 Keywords Search (AC自动机板子题)
- ui-router
- ItemDecoration解析(二) onDraw onDrawOver