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

  1. 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 ...

  2. POJ 2193 Lenny's Lucky Lotto Lists (DP)

    题目链接 题意 : 给你两个数N和M,让你从1到M中找N个数组成一个序列,这个序列需要满足的条件是后一个数要大于前一个数的两倍,问这样的序列有多少,输出. 思路 : dp[i][j]代表着长度为 i ...

  3. soj1011. Lenny's Lucky Lotto

    1011. Lenny's Lucky Lotto Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Lenny like ...

  4. HDU 1087 简单dp,求递增子序列使和最大

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  5. Codeforces Round #260 (Div. 1) A. Boredom (简单dp)

    题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. ...

  6. 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 ...

  7. 简单dp --- HDU1248寒冰王座

    题目链接 这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350]) 代码如下: #include<iostream ...

  8. poj2385 简单DP

    J - 简单dp Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit ...

  9. hdu1087 简单DP

    I - 简单dp 例题扩展 Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     ...

随机推荐

  1. servlet 返回json 数据

    后端的数据需要返回简单的json数据: 发现通过双引号和单引号:" {  'name':123 }  "的方式返回失败. 需要通过\转义里边的双引号: response.getWr ...

  2. 深度神经网络在量化交易里的应用 之二 -- 用深度网络(LSTM)预测5日收盘价格

        距离上一篇文章,正好两个星期. 这边文章9月15日 16:30 开始写. 可能几个小时后就写完了.用一句粗俗的话说, "当你怀孕的时候,别人都知道你怀孕了, 但不知道你被日了多少回 ...

  3. 闲话和grunt

    一年半没更新是因为自己转岗了,android framework+system转前端,可以想象过程之苦逼,苦成了一首诗:很烦很烦/非常烦/非常非常十分烦/特别烦特烦/极其烦/贼烦/简直烦死了/啊——. ...

  4. AOP TP框架有感

    自学AOP感觉面向切面编程是一种利器,同时也是一种潜在的威胁.他就像一把手术刀,无论哪个器官有问题他都可以把他切开,修复它,但是使用的多了身体也会受不了... AOP应该算是面向对象的一种补充,但是, ...

  5. mybaties-plus入门

    目前正在维护的公司的一个项目是一个ssm架构的java项目,dao层的接口有大量数据库查询的方法,一个条件变化就要对应一个方法,再加上一些通用的curd方法,对应一张表的dao层方法有时候多达近20个 ...

  6. Beta阶段事后诸葛亮分析

    1.总结的提纲内容 a. 项目管理之事后诸葛亮会 设想和目标 1.我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 我们的软件主要解决用户无意识花钱,无法清楚看见钱去 ...

  7. Swing-JList选择事件监听器ListSelectionListener-入门

    当JList中的元素被选中时,选择事件将被触发.对于JTable也是一样,你可以把它看做是多个并列的JList.那么,如果程序需要对该事件做出响应,需要以下步骤: (1)创建一个实现了 ListSel ...

  8. 201521123081《Java程序设计》 第8周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 参考资料:XMIND 1.2 选做:收集你认为有用的代码片段 2. 书面作业 本次作业题集 集合 Q1. Li ...

  9. 201521123118《java程序与设计》第8周学习总结

    1. 本周学习总结 1. 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 2. 书面作业 1. List中指定元素的删除(题目4-1) 1.1 实验总结 Scanner sc = new ...

  10. Java实现Windows平台下Ping的最佳方法

    先上结论:通过调用系统自带的Ping命令来实现,使用exitValue()值来判断Ping的结果.按照惯例,0表示ok,1表示不通. private static void pingTest1() t ...