hdu 5568(dp+大数模拟)
来源:互联网 发布:apache tomcat8.0下载 编辑:程序博客网 时间:2024/05/04 12:36
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5568
官方题解:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn = 105;struct Bign { int n, s[maxn<<1]; Bign (int t = 0) { init(); s[0] = t; } void init () { n = 1; memset(s, 0, sizeof(s)); } void add(const Bign& a) { int res = 0; for (int i = 0; i < a.n || i < n; i++) { if (i < a.n) res += a.s[i]; if (i < n) res += s[i]; s[i] = res % 10; res /= 10; } n = max(a.n, n); while (res) { s[n++] = res % 10; res /= 10; } }}dp[maxn][maxn], ONE(1);int N, K, A[maxn];void solve () { Bign ans(0); for (int i = 1; i <= N; i++) { for (int j = 1; j <= K; j++) dp[i][j].init(); } for (int i = 1; i <= N; i++) { dp[i][1].add(ONE); ans.add(dp[i][K]); for (int j = i + 1; j <= N; j++) if (A[i] < A[j]) { for (int k = 2; k <= K; k++) dp[j][k].add(dp[i][k-1]); } } for (int i = ans.n-1; i >= 0; i--) printf("%d", ans.s[i]); printf("\n");}int main() { while (scanf("%d%d", &N, &K) == 2) { for (int i = 1; i <= N; i++) scanf("%d", &A[i]); solve(); } return 0;}
0 0
- hdu 5568(dp+大数模拟)
- HDU 5106 Bits Problem(数位DP->二进制大数模拟)@
- HDU 5568 DP大数
- hdu 5568 sequence2(dp + 大数)
- HDU 5568:sequence2 大数+DP
- HDU 5568 sequence2(大数+DP)
- [HDU 5568] sequence2 dp+大数
- HDU 5568 dp+大数板子
- HDU1502 Regular Words(DP+大数模拟)
- HDU 1013_Digital Roots(大数&模拟)
- hdu 5585 Numbers(字符串模拟大数)
- HDU 1047(大数相加)(数组模拟)
- hdu 5718 大数模拟
- HDU 1502 Regular Words(大数+dp)
- HDU 1297 (dp + 大数加法)
- HDU 1502 dp + 大数
- HDU 1502 DP+大数
- hdu 1502 大数dp
- jdk 线程池 threadPoolExecutor 源码剖析
- DataWindow.Net 2.5 配置
- 称重指示牌设备选型方案
- 几个Linux命令
- object类 wait与notify
- hdu 5568(dp+大数模拟)
- XXXXXXXX系统失败总结
- [Leetcode]54. Spiral Matrix
- Android简易画板:
- 动态规划 III——B - Apple Catching
- 自动化收购系统目前存在的问题
- 短信验证码注册
- object wait notify 实例一则
- 《专分散收智能系统》错误提示