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. [链接]最短路径的几种算法[迪杰斯特拉算法][Floyd算法]

    最短路径—Dijkstra算法和Floyd算法 http://www.cnblogs.com/biyeymyhjob/archive/2012/07/31/2615833.html Dijkstra算 ...

  2. McAfee 与 360使用感受

    运维给配的 win 10.4G内存 ,装的 McAfee,每次开机啥事不干内存去了55%, 开齐qq.微信.vscode.浏览器就要冲90%,再多开几个网页电脑就卡得很, 最近,卡死机了.. 然后看了 ...

  3. 递推2--过河卒(Noip2002)

    递推2--过河卒(Noip2002) 一.心得 写出递推公式就OK了,具体编程还是很简单的 二.题目及分析 过河卒(NOIp2002) [问题描述] 棋盘上A点有一个过河卒,需要走到目标B点.卒行走的 ...

  4. centos系统lvm的安装

    今天安装redhat6.1在分区时提示”可引导分区不能位于逻辑卷上“,原来linux的引导区不能放在逻辑卷上. 解决方法: 1.先建立一个物理分区划给/boot分区 2.剩下的空间划给lvm. 然后开 ...

  5. 雷林鹏分享:C# 泛型(Generic)

    C# 泛型(Generic) 泛型(Generic) 允许您延迟编写类或方法中的编程元素的数据类型的规范,直到实际在程序中使用它的时候.换句话说,泛型允许您编写一个可以与任何数据类型一起工作的类或方法 ...

  6. LICEcap 和 FS Capture入门教程

    上一篇介绍了如何使用 Visio 图形图表工具,文中贴了一张gif图,留言的小伙伴们迫不及待想知道如何录制 GIF 图,强哥姑且卖弄一次,把 PC 端截图工具和教程分享给大家,分别为 LICEcap ...

  7. Wannafly挑战赛20-A,B

    A-链接:https://www.nowcoder.com/acm/contest/133/A来源:牛客网 题目描述 现在有一棵被Samsara-Karma染了k种颜色的树,每种颜色有着不同的价值 A ...

  8. python独角兽 Flask + Gunicorn

    1.构建程序运行所需的虚拟环境 安装Miniconda 创建虚拟环境 添加程序运行依赖包 添加Gunicorn依赖 方式一:最简单的使用 easy_install 安装或者更新 方式二:下载源码安装 ...

  9. spring boot 学习番外篇:超快速项目初始化

    超快速完成 Spring Boot 项目初始化 最近,在浏览 SPRING 官网时,发现一个超级方便的小工具,可以帮助我们快速创建一个 Spring Boot 项目,前提就是你能连接互联网. 依赖 支 ...

  10. CentOS下tar解压 gz解压 bz2等各种解压文件使用方法

    .tar  解包:tar xvf FileName.tar  打包:tar cvf FileName.tar DirName  (注:tar是打包,不是压缩!)  ———————————————  . ...