题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=5568

题意:

求所有长度为k的严格升序子序列的个数。

题解:

令dp[i][k]表示以i结尾的长度为k的所有严格升序子序列的个数,则有状态转移:dp[i][k]+=dp[j][k-1](其中,arr[i]>arr[j],并且i>j);

最后答案为dp[1][k]+...dp[n][k]。

代码:

 import java.util.*;
import java.math.*;
public class Main { public static void main(String args[]){
Scanner cin = new Scanner(System.in);
final int maxn=;
int n,k;
int[] arr=new int[maxn]; while(cin.hasNext()){
n=cin.nextInt();
k=cin.nextInt();
BigInteger[][] dp=new BigInteger[maxn][maxn];
for(int i=;i<=n;i++){
arr[i]=cin.nextInt();
}
for(int i=;i<=n;i++){
for(int j=;j<=n;j++) dp[i][j]=BigInteger.ZERO;
}
for(int i=;i<=n;i++) dp[i][]=BigInteger.ONE;
for(int kk=;kk<=k;kk++){
for(int i=;i<=n;i++){
for(int j=i-;j>=;j--){
if(arr[i]>arr[j]){
dp[i][kk]=dp[i][kk].add(dp[j][kk-]);
}
}
}
}
BigInteger ans = BigInteger.ZERO;
for(int i=;i<=n;i++) ans=ans.add(dp[i][k]);
System.out.println(ans.toString());
}
}
}

HDU 5568 sequence2 区间dp+大数的更多相关文章

  1. Hdu 5568 sequence2 高精度 dp

    sequence2 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=556 ...

  2. hdu 5396 Expression(区间dp)

    Problem Description Teacher Mai has n numbers a1,a2,⋯,anand n−1 operators("+", "-&quo ...

  3. You Are the One HDU - 4283 (区间DP)

    Problem Description The TV shows such as You Are the One has been very popular. In order to meet the ...

  4. Dire Wolf HDU - 5115(区间dp)

    Dire Wolf Time Limit: 5000/5000 MS (Java/Others)    Memory Limit: 512000/512000 K (Java/Others)Total ...

  5. hdu 4579 博弈+区间dp

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4597 #include <cstdio> #include <cstring> ...

  6. Hdu 2513 区间DP

    Cake slicing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  7. HDU 4283---You Are the One(区间DP)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4283 Problem Description The TV shows such as Y ...

  8. HDU 4293---Groups(区间DP)

    题目链接 http://acm.split.hdu.edu.cn/showproblem.php?pid=4293 Problem Description After the regional con ...

  9. hdu 4597 + uva 10891(一类区间dp)

    题目链接:http://vjudge.net/problem/viewProblem.action?id=19461 思路:一类经典的博弈类区间dp,我们令dp[l][r]表示玩家A从区间[l, r] ...

随机推荐

  1. (一)、NodeJS (转载)

    NodeJS基础                                                 ------ 转载自阿里巴巴 什么是NodeJS JS是脚本语言,脚本语言都需要一个解 ...

  2. 软件工程 speedsnail 冲刺5

    2015-5-9 完成任务:学习了黑马android教学视频10\11\12集,填写游戏人的姓名功能为明天的记分板准备: 遇到问题: 问题1 Suspicious method call; shoul ...

  3. Windows Server 2008 R2 实现多用户连接远程桌面

    前提 1. 确认自己的计算机开启了远程连接 2. 在远程桌面会话主机配置中将"限制每个用户只能进行一个会话"的勾去掉. 实现方法 1. 需要在角色里面安装远程桌面服务: 2. 在用 ...

  4. Retrieve Only First x Rows

    From time to time you may have the need to grab the top X number of rows returned from a table. For ...

  5. Vue.js学习 Item6 -- Class 与 样式绑定

    数据绑定一个常见需求是操作元素的 class 列表和它的内联样式.因为它们都是 attribute,我们可以用 v-bind 处理它们:只需要计算出表达式最终的字符串.不过,字符串拼接麻烦又易错.因此 ...

  6. 在Spark中使用Kryo序列化

    spark序列化  对于优化<网络性能>极为重要,将RDD以序列化格式来保存减少内存占用. spark.serializer=org.apache.spark.serializer.Jav ...

  7. QQl聊天消息

    Activity: package com.zzw.qqchat; import java.util.ArrayList; import java.util.HashMap; import andro ...

  8. js控制div动起来

    代码: <html> <head> <title>让div动的测试</title> <script language="javascri ...

  9. 利用HttpWebRequest访问WebApi

    WebApi现在越来越流行,下面给出利用HttpWebRequest访问WebApi的工具方法: 1.利用基准URL和参数字典生成完整URL /// <summary> /// 生成URL ...

  10. 简答的理解C语言中的各种类型函数

    1.变参函数 变长参数的函数即参数个数可变.参数类型不定 的函数.最常见的例子是printf函数.scanf函数和高级语言的Format函数.在C/C++中,为了通知编译器函数的参数个数和类型可变(即 ...