hdu4028 The time of a day[map优化dp]
The time of a day
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 1297 Accepted Submission(s): 594
The wise of the island decide to choose some of the N pointers to make the length of the day greater or equal to M. They want to know how many different ways there are to make it possible.
For each test cases, there are only one line contains two integers N and M, indicating the number of pointers and the lower bound for seconds of a day M. (1 <= N <= 40, 1 <= M <= 263-1)
5 5
10 1
10 128
Case #2: 1023
Case #3: 586
#include<map>
#include<cstdio>
using namespace std;
typedef long long ll;
map<ll,ll>f[];ll m,ans;int n,cas,Cas;
map<ll,ll>::iterator it,ii;
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int main(){
f[][]=;
for(int i=;i<=;i++){
f[i]=f[i-];
f[i][i]++;
for(it=f[i-].begin();it!=f[i-].end();it++){
f[i][lcm(it->first,i)]+=it->second;
}
}
for(scanf("%d",&Cas),cas=;cas<=Cas;cas++){
scanf("%d%I64d",&n,&m);printf("Case #%d: ",cas);
ans=;
for(it=f[n].begin();it!=f[n].end();it++){
if(it->first>=m) ans+=it->second;
}
printf("%I64d\n",ans);
}
return ;
}
hdu4028 The time of a day[map优化dp]的更多相关文章
- Codeforces 977F - Consecutive Subsequence - [map优化DP]
题目链接:http://codeforces.com/problemset/problem/977/F 题意: 给定一个长度为 $n$ 的整数序列 $a[1 \sim n]$,要求你找到一个它最长的一 ...
- Consecutive Subsequence CodeForces - 977F (map优化DP)·
You are given an integer array of length nn. You have to choose some subsequence of this array of ma ...
- CodeForces - 512B Fox And Jumping[map优化dp]
B. Fox And Jumping time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- BZOJ 3357 [Usaco2004]等差数列:map优化dp
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3357 题意: 给你n个数a[i],让你找出一个最长的是等差数列的子序列. 题解: 表示状态 ...
- 【java】itoo项目实战之大数据查询之使用 new map 优化hibernate之级联查询
在我的上一篇博客<[java]itoo项目实战之hibernate 懒载入优化性能>中,我曾提到过学生数据有2万条,查询数据十分的慢,这是让人非常受不了的事情.看着页面进度条一直转着圈圈, ...
- 单调队列优化DP,多重背包
单调队列优化DP:http://www.cnblogs.com/ka200812/archive/2012/07/11/2585950.html 单调队列优化多重背包:http://blog.csdn ...
- 优化DP的奇淫技巧
DP是搞OI不可不学的算法.一些丧心病狂的出题人不满足于裸的DP,一定要加上优化才能A掉. 故下面记录一些优化DP的奇淫技巧. OJ 1326 裸的状态方程很好推. f[i]=max(f[j]+sum ...
- BZOJ 1010: 玩具装箱toy (斜率优化dp)
Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1... ...
- hdu 2829 Lawrence(四边形不等式优化dp)
T. E. Lawrence was a controversial figure during World War I. He was a British officer who served in ...
随机推荐
- 字符数组在C++、C#等语言中的操作
1.C++中操作数组 #include <iostream> using namespace std; int length(char []); void output_frequency ...
- Entity Framework开发介绍
一.Entity Framework概要 Entity Framework是微软的Object Relational Mapper(对象关系映射),也就是我们平常说的ORM,它可以让应用程序开发者将关 ...
- php BC高精确度函数库
#两个高精度数比较 #int bccomp ( string $left_operand , string $right_operand [, int $scale ] ) #$left=$right ...
- Javascript 你不知道的事,好吧,是我不知道的事
NaN表示一个不能产生正常结果的运算结果.它不等于任何值,包括它自己.可以用isNaN(number)来检测. 同Java中的字符串一样,JS中的字符串是不可变的.也就是说一旦字符串被创建,就无法改变 ...
- JavaScript入门学习书籍的阶段选择
对于许多想学习 JavaScript 的朋友来说,无疑如何选择入门的书籍是他们最头疼的问题,或许也是他们一直畏惧,甚至放弃学习 JavaScript 的理由.在 JavaScript 方面,自己不是什 ...
- HBase系统入门--整体介绍
转自:http://www.aboutyun.com/thread-8957-1-2.html 问题导读:1.HBase查询与写入哪个更好一些?2.HBase面对复杂操作能否实现?3.Region服务 ...
- 关于Cocos2d-x的数据存储
Cocos2d-x对数据的存储没有用到数据库,但是有用到一个类似数据库的小型数据库,就是数据存储.存储后的数据用XML的文件格式保存在C:\Users\Administrator\AppData\Lo ...
- e555. 在Applet中播放音频
// See also e551 精简的Applet public void init() { // Load audio clip AudioClip ac = getAudioClip(getDo ...
- : error C3861: “Sleep”: 找不到标识符
编译的时候:error C3861: “sleep”: 找不到标识符,是什么原因啊?编译的时候:error C3861: “sleep”: 找不到标识符,是什么原因啊?哪位好心的哥哥告诉我吧,分全是你 ...
- XML 入门
XML语法 所有 XML 元素都须有关闭标签 XML 标签对大小写敏感 XML 必须正确地嵌套 XML 文档必须有根元素 就像HTML一样,HTML必须有<html>根元素.XML也必须有 ...