POJ 2193 Lenny's Lucky Lotto Lists(简单二维dp)
来源:互联网 发布:乎伦贝尔湖 编辑:程序博客网 时间:2024/06/05 11:51
一道水题,竟然脑子抽筋比赛时没做出来啊。sad、、、以位数和结尾数字进行dp。
Lenny's Lucky Lotto Lists
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2068 Accepted: 881
Description
Lenny likes to play the game of lotto. In the lotto game, he picks a list of N unique numbers in the range from 1 to M. If his list matches the list of numbers that are drawn, he wins the big prize.
Lenny has a scheme that he thinks is likely to be lucky. He likes to choose his list so that each number in it is at least twice as large as the one before it. So, for example, if N = 4 and M = 10, then the possible lucky lists Lenny could like are:
Thus Lenny has four lists from which to choose.
Your job, given N and M, is to determine from how many lucky lists Lenny can choose.
Lenny has a scheme that he thinks is likely to be lucky. He likes to choose his list so that each number in it is at least twice as large as the one before it. So, for example, if N = 4 and M = 10, then the possible lucky lists Lenny could like are:
1 2 4 8
1 2 4 9
1 2 4 10
1 2 5 10
Thus Lenny has four lists from which to choose.
Your job, given N and M, is to determine from how many lucky lists Lenny can choose.
Input
There will be multiple cases to consider from input. The first input will be a number C (0 < C <= 50) indicating how many cases with which you will deal. Following this number will be pairs of integers giving values for N and M, in that order. You are guaranteed that 1 <= N <= 10, 1 <= M <= 2000, and N <= M. Each N M pair will occur on a line of its own. N and M will be separated by a single space.
Output
For each case display a line containing the case number (starting with 1 and increasing sequentially), the input values for N and M, and the number of lucky lists meeting Lenny's requirements. The desired format is illustrated in the sample shown below.
Sample Input
34 102 202 200
Sample Output
Case 1: n = 4, m = 10, # lists = 4Case 2: n = 2, m = 20, # lists = 100Case 3: n = 2, m = 200, # lists = 10000
#include <algorithm>#include <iostream>#include <stdlib.h>#include <string.h>#include <iomanip>#include <stdio.h>#include <string>#include <queue>#include <cmath>#include <stack>#include <map>#include <set>#define eps 1e-7#define M 1000100//#define LL __int64#define LL long long#define INF 0x3fffffff#define PI 3.1415926535898#define MOD 1000000007using namespace std;const int maxn = 2020;LL dp[12][maxn];int main(){ int T; cin >>T; for(int t = 1; t <= T; t++) { int n, m; cin >>n>>m; memset(dp, 0 , sizeof(dp)); for(int i = 0; i <= m; i++) dp[1][i] = 1; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) for(int k = j+1; k <= m; k++) if(k >= 2*j) dp[i][k] += dp[i-1][j]; LL sum = 0; for(int i = 1 ;i <= m; i++) sum += dp[n][i]; cout<<"Case "<<t<<": n = "<<n<<", m = "<<m<<", # lists = "<<sum<<endl; } return 0;}
0 0
- POJ 2193 Lenny's Lucky Lotto Lists(简单二维dp)
- poj 2193 Lenny's Lucky Lotto Lists 简单dp
- poj 2193 Lenny's Lucky Lotto Lists
- POJ 2193 Lenny's Lucky Lotto Lists
- ZOJ 2402 Lenny's Lucky Lotto Lists(简单DP)
- pku2193 Lenny's Lucky Lotto Lists
- zoj 2402 - Lenny's Lucky Lotto Lists
- zoj 2402 Lenny's Lucky Lotto Lists
- ZOJ2402 Lenny's Lucky Lotto List 简单DP
- 1011. Lenny's Lucky Lotto
- Scily 1011. Lenny's Lucky Lotto
- Sicily 1011 Lenny's Lucky Lotto
- [sicily online]1011. Lenny's Lucky Lotto
- Scily 1011. Lenny's Lucky Lotto
- sicily 1011. Lenny's Lucky Lotto
- Sicily 1011. Lenny's Lucky Lotto
- Sicily 1011.Lenny's Lucky Lotto
- Sicily 1011. Lenny's Lucky Lotto
- 设置UIButton的文字显示位置、字体的大小、字体的颜色
- 减肥不可忽视的八大细节
- 2014-4-11第一篇博文
- 安卓开发之双击返回键退出程序
- tomcat启动一闪而过
- POJ 2193 Lenny's Lucky Lotto Lists(简单二维dp)
- 如何制作一个横版格斗过关游戏 Cocos2d-x 2.0.4
- 位图像素的颜色——杭电携程编程大赛 (预赛第二场)
- Transaction has been rolled back because it has been marked as rollback .
- WIN7系统MySQL安装教程
- eclipse debug hadoop
- cocos2dx 资料整理
- ios 内存泄露
- 第五周作业——有向图邻接表表示及反向图构造