HDU 4028 The time of a day
来源:互联网 发布:mac 7z解压软件下载 编辑:程序博客网 时间:2024/04/28 03:52
看完题目后觉得要用dp,但是数据量太大,搞不定。看了解题报告后才知道可以用map来离散化。代码如下:
#include <iostream>#include <cstdio>#include <map>using namespace std;const int MAXN = 42;__int64 gcd(__int64 x, __int64 y){ if (y == 0) return x; return gcd(y, x % y);}__int64 lcm(__int64 x, __int64 y){ return x / gcd(x, y) * y;}int main(){ int t; __int64 n, m, ans; map<__int64, __int64> dp[MAXN]; map<__int64, __int64>::iterator mit; dp[1][1] = 1; for (int i = 2; i <= 40; ++i) { dp[i]= dp[i-1]; dp[i][i]++; for (mit = dp[i-1].begin(); mit != dp[i-1].end(); ++mit) { dp[i][lcm(i, mit->first)] += mit->second; } } scanf("%d", &t); for (int cas = 1; cas <= t; ++cas) { scanf("%I64d %I64d", &n, &m); ans = 0; for (mit = dp[n].begin(); mit != dp[n].end(); ++mit) { if (mit->first >= m) ans += mit->second; } printf("Case #%d: %I64d\n", cas, ans); } return 0;}
- HDU 4028 The time of a day
- HDU 4028--The time of a day
- hdu-4028 The time of a day
- HDU 4028 The time of a day
- hdu 4208 - The time of a day
- HDU 4028 The time of a day STL 模拟题
- HDU 4028 The time of a day(动态规划)
- HDU - 4028 The time of a day(离散+DP)
- HDU 4028 The time of a day(DP)
- hdu 4028 The time of a day(离散化dp)
- HDU 4028 The time of a day(11年上海 离散化DP)
- HDU 4028 The time of a day By Assassin dp+离散化!
- hdu4028 The time of a day (map+dp)
- hdu4028The time of a day
- A Day in the Life of IT
- Day in the Life of a Googler
- 【SPOJ-LCM】The Time of Day【计数DP】【离散化】
- Can't adjust the time of day: Invalid argument
- sqlserver分布式存储过程
- 临近过年的一点感想
- 向大家推荐一个非常好用的JS日历控件My97DatePicker
- treeview 节点 父节点 递归
- 流年不利
- HDU 4028 The time of a day
- 文件加密解密
- 备注一些后续有用的信息
- 通过分区(Partition)提升MySQL性能
- 字库 TTC TTF
- 一个不错的shell 脚本教程
- Android4.0 Launcher 源码分析系列(一)
- TPS6204x 1.2A/1.25MHz高效步降转换器
- 技巧篇:如何重写基类的事件