ZOJ2402 Lenny's Lucky Lotto List 简单DP
Lenny's Lucky Lotto Lists
Time Limit: 2 Seconds Memory Limit:65536 KB
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:
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. 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
3
4 10
2 20
2 200
Sample Output
Case 1: n = 4, m = 10, # lists = 4
Case 2: n = 2, m = 20, # lists = 100
Case 3: n = 2, m = 200, # lists = 10000
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cmath>
using namespace std;
#define LL long long
LL q[][];
void _dp()
{
for(int i=;i<=;i++)
q[][i]=;
for(int i=;i<=;i++)
{
for(int j=pow(,i-);j<=;j++)
{
for(int k=j/;k>=;k--)
q[i][j]+=q[i-][k];
}
};
}
int main()
{
int n;
_dp();
cin>>n;
for(int i=;i<=n;i++)
{
LL ans=;
int x,y;
scanf("%d%d",&x,&y);
for(int j=pow(,x-);j<=y;j++)
ans+=q[x][j];
printf("Case %d: n = %d, m = %d, # lists = %lld\n",i,x,y,ans); }
return ;
}
ZOJ2402 Lenny's Lucky Lotto List 简单DP的更多相关文章
- ZOJ2402 Lenny's Lucky Lotto List 简单DP
Lenny's Lucky Lotto Lists Time Limit: 2 Seconds Memory Limit:65536 KB Lenny likes to play the g ...
- POJ 2193 Lenny's Lucky Lotto Lists (DP)
题目链接 题意 : 给你两个数N和M,让你从1到M中找N个数组成一个序列,这个序列需要满足的条件是后一个数要大于前一个数的两倍,问这样的序列有多少,输出. 思路 : dp[i][j]代表着长度为 i ...
- soj1011. Lenny's Lucky Lotto
1011. Lenny's Lucky Lotto Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Lenny like ...
- HDU 1087 简单dp,求递增子序列使和最大
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- Codeforces Round #260 (Div. 1) A. Boredom (简单dp)
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...
- codeforces Gym 100500H A. Potion of Immortality 简单DP
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/a ...
- 简单dp --- HDU1248寒冰王座
题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...
- poj2385 简单DP
J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:65536KB 64bit ...
- hdu1087 简单DP
I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS Memory Limit:32768KB ...
随机推荐
- grunt对象之api
grunt已经扯了七篇了,殊为不易.最后一篇扯点早应该提及的东西,就是module.exports = function(grunt) {}传入的这个grunt.之前的代码grunt一般只出现在Gru ...
- [我所理解的REST] 2.REST用来干什么的?
笔者每当遇到一个新事物的想去了解的时候,总是会问上自己第一个问题,这个新事物是干什么用的?在解释我所理解的REST这个过程中也不例外,这篇博客我们先关注一下REST是干什么用的,然后后续再解释REST ...
- Spring mvc 转发、重定向
spring控制器最后返回一个ModelAndView(urlName),其中urNamel可以是一个视图名称,由视图解析器负责解析后将响应流写回客户端;也可以通过redirect/forward:u ...
- 【★】IT界8大恐怖预言
IT界的8大恐怖预言 本文字数:3276 建议阅读时间:你开心就好 第三次科技革命已经进入白热化阶段---信息技术革命作为其中最主要的一环已经奠定了其基本格局和趋势.OK大势已定,根据目前的形势,小编 ...
- 转: 【Java并发编程】之二十一:并发新特性—阻塞队列和阻塞栈(含代码)
转载请注明出处:http://blog.csdn.net/ns_code/article/details/17511147 阻塞队列 阻塞队列是Java5并发新特性中的内容,阻塞队列的接口是Java. ...
- 团队作业6——展示博客(Alpha)
一.团队简介 李永豪(PM):项目经理,后台开发人员,协调团队内部的工作及开发团队之间的工作 杨海亮:后台开发人员,测试人员,熟悉java语言,编写java代码 郑靖涛:后台开发人员,测试人员,安卓程 ...
- SNS团队Beta阶段第六次站立会议(2017.5.27)
1.立会照片 2.每个人的工作 成员 今天已完成的工作 明天计划完成的工作 罗于婕 发音图标的改进 对界面各部分的图标进行完善.美化 龚晓婷 对于历史记录功能的测试 对于历史记录功能进一步完善 林仕庄 ...
- 201521123091 《Java程序设计》第12周学习总结
Java 第十一周总结 第十一周的作业. 目录 1.本章学习总结 2.Java Q&A 3.码云上代码提交记录及PTA实验总结 4.课后阅读 1.本章学习总结 1.1 以你喜欢的方式(思维导图 ...
- 个人作业2-英语学习案例app分析
第一部分 调研, 评测 (软件的bug,功能评测,黑箱测试, 第8章 用户调研, 12 章 软件的用户体验) 下载并使用,描述最简单直观的个人第一次上手体验. ①个人感觉还不错,词典的首页页面挺好看的 ...
- Java中 == 和 equals()详解
java中的数据类型分为两种: 一 .基本数据类型: byte.short.int.long.float.double.char.boolean 比较它们需要用 == ,比较的是它们的值是否相等 ...