UVALive 4235 Recursively Palindromic Partitions
来源:互联网 发布:博易大师画横虚线源码 编辑:程序博客网 时间:2024/05/16 04:50
http://livearchive.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2236
dp[i]: as i has dp[i] RPP
and
dp[i] = dp[i / 2] + $\sum_{j = 1}^{i}dp[(n - i) / 2]$
#include <cstdio>#include <cstdlib>#include <iostream>#include <cstring>#include <string>#include <vector>#include <map>#include <algorithm>#include <cctype>#include <queue>#include <stack>using namespace std;#define Rep(c, a, b) for (int c = (a); c < (b); c++)#define Nre(c, a, b) for (int c = (a); c > (b); c--)#define MAXN (1100)typedef long long LL;int dp[MAXN];int DFS(int n){if (dp[n]) return dp[n];if (n == 0) return dp[n] = 1;if (n == 1) return dp[n] = 1;int res = 0;if (n % 2 == 0) res += DFS(n / 2);Rep(i, 1, n + 1) if ((n - i) % 2 == 0)res += DFS((n - i) / 2);return dp[n] = res;}int main(){int T, n, Cas = 1;Rep(i, 1, 1001) DFS(i);scanf("%d", &T);while (T--) scanf("%d", &n), printf("%d %d\n", Cas++, dp[n]);return 0;}
- UVALive 4235 Recursively Palindromic Partitions
- POJ3790 Recursively Palindromic Partitions
- Sicily 1626 Recursively Palindromic Partitions
- TOJ 3153 Recursively Palindromic Partitions
- 南邮 OJ 1534 D ? Recursively Palindromic Partitions
- poj 3790 Recursively Palindromic Partitions dp水题
- Partitions
- UNIMODAL PALINDROMIC DECOMPOSITIONS - POJ 1221 UVaLive 2560 dp
- Thinking recursively
- /proc/partitions
- Recursively CopyDirectory(Source,Dest)
- Linkedlist recursively reverse
- getWritableDatabase called recursively
- [LeetCode] Symmetric Tree - Recursively
- getDatabase called recursively
- UVALive
- UVALive
- UVALive
- OPENGL 变换视图模型变换与部分透视变换
- HDU 3265 - Posters
- spring中bean属性scope介绍
- liveoj 4238 - Area of Polycubes(搜索)
- 盐焗鸡 电压力锅版
- UVALive 4235 Recursively Palindromic Partitions
- Picture Control 打开图片
- xp局域网设置和xp无法访问局域网的解决方案
- 打包学生管理系统之感
- 最长公共子序列(LCS)的两种求解方法
- LDD3源码分析之内存映射
- wince下的蓝牙串口通信
- waterfox(水狐)——火狐的非官方64位版浏览器(汉化)
- [EXCEL每日一学]绝对引用和相对引用