Gym 100090D Insomnia
从 n 变到 1,有多少种方案?
打表记忆化。
#include <bits/stdc++.h> using namespace std; int n;
int dp[];
int dfs(int n) {
if(n==)
return ;
if(dp[n]>)
return dp[n];
int cnt=;
for(int i=;i<=n;i++) {
if(n%i==)
cnt+=dfs(n/i);
}
return dp[n]=cnt;
} int main()
{
memset(dp,,sizeof(dp));
scanf("%d",&n);
printf("%d\n",dfs(n)); return ;
}
Gym 100090D Insomnia的更多相关文章
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- ACM: Gym 101047K Training with Phuket's larvae - 思维题
Gym 101047K Training with Phuket's larvae Time Limit:2000MS Memory Limit:65536KB 64bit IO F ...
- ACM: Gym 101047E Escape from Ayutthaya - BFS
Gym 101047E Escape from Ayutthaya Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I6 ...
- ACM: Gym 101047B Renzo and the palindromic decoration - 手速题
Gym 101047B Renzo and the palindromic decoration Time Limit:2000MS Memory Limit:65536KB 64 ...
- Gym 101102J---Divisible Numbers(反推技巧题)
题目链接 http://codeforces.com/gym/101102/problem/J Description standard input/output You are given an a ...
- Gym 100917J---Judgement(01背包+bitset)
题目链接 http://codeforces.com/gym/100917/problem/J Description standard input/outputStatements The jury ...
- Gym 100917J---dir -C(RMQ--ST)
题目链接 http://codeforces.com/gym/100917/problem/D problem description Famous Berland coder and IT mana ...
- Gym 101102D---Rectangles(单调栈)
题目链接 http://codeforces.com/gym/101102/problem/D problem description Given an R×C grid with each cel ...
- Gym 101102C---Bored Judge(区间最大值)
题目链接 http://codeforces.com/gym/101102/problem/C problem description Judge Bahosain was bored at ACM ...
随机推荐
- shell read line
cat >b <<EOF line1 line2 line3 EOF # 方法1 while read line do echo ${line} done < <(cat ...
- SpringMVC DeferedResult和servlet3.1 AsyncContext异步请求
先看一个简单的示例: @RequestMapping("/getFuture") public Future<String> getFuture() { System. ...
- windows查看网络常用cmd命令
一.ping 主要是测试本机TCP/IP协议配置正确性与当前网络现状. ping命令的基本使用格式是: ping IP地址/主机名/域名 [-t] [-a] [-n count] [-l size] ...
- php数组·的方法3-数组指针
/* * 数组指针函数 * */ //key() current() 指针一直停在第一位 不会下移 echo '<hr>'; $arr5 = array('name' => 'hxq ...
- sqlt 之 分析 DB upgrade 导致SQL 性能下降 的方法 xplore
https://blog.csdn.net/lukeUnique/article/details/79331779 https://mauro-pagano.com/2014/10/27/when-t ...
- jquery dataTable 自定义 Button及按钮事件
参考网址:http://stackoverflow.com/questions/18134913/jquery-datatabletabletool-custom-buttons-calling-ev ...
- (转)Python作业day2购物车
Python作业day2购物车 原文:https://www.cnblogs.com/spykids/p/5163108.html 流程图: 实现情况: 可自主注册, 登陆系统可购物,充值(暂未实现) ...
- Unity3D跨平台动态库编译---记kcp基于CMake的各平台构建实践
一 为什么需要动态库 1)提供原生代码(native code)的支持,也叫原生插件,但是我实践的是c/cpp跨平台动态库,这里不具体涉及安卓平台java库和ios平台的objectc库构建. 2)某 ...
- static 和 final 和 static final
众所周知,static 是静态修饰关键字:可以修饰变量,程序块,方法,类. 1.修饰变量. 得知:如果static修饰的是变量,则JVM会将将其分配在内存堆上,该变量就与对象无关,所有对该变量的引用都 ...
- mysql连接查看
1:查看当前连接 mysql> show status like 'Threads%'; +-------------------+-------+ | Variable_name | ...