题目链接:

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. 调试工具-fiddler

    本地资源替换线上调试 Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网 之间的http通讯,设置断点,查看所有的“进出”Fiddler的数据(指cookie,html ...

  2. 改变tabbar的高度做法

    UITabBarController *tabBarController =[[UITabBarController alloc] init]; CGRect frame = self.window. ...

  3. luigi学习8--使用中央调度器

    --local-scheduler一般用在开发阶段,这在一个产品中是不建议这样使用的.使用中央调度器有两个目的: 保证两个相同的task不会同时运行两次 提供一个可视化的界面 注意:中央调度器并不会帮 ...

  4. dump buffer cache

    1.基础内容: ALTER SESSION SET EVENTS 'immediate trace name buffers level n'; n取值意义: 1 只转储buffer header. ...

  5. rails使用 rake db:migrate 提示 Migrations are pending; run 'rake db:migrate RAILS_ENV=development' to resolve this issue.

    首先得特么建立数据库 : rake db:create 实际问题是没有int应该用integer http://www.rubycc.com/column/rails3.2.3/rails.htm

  6. java读取各类型的文件

    java读取各类型的文件 用到的几个包 bcmail-jdk14-132.jar/bcprov-jdk14-132.jar/checkstyle-all-4.2.jar/FontBox-0.1.0-d ...

  7. Node.js中的模块化

    每天一篇文章来记录记录自己的成长吧.大二,该静心了.加油~ 好了,废话不多说,今天说说nodejs中的模块化.(注:此文为自己对书nodejs实战的总结) nodejs一个重要的特性就是模块化,模块就 ...

  8. Gearman 安装使用教程

    Gearman是一个分发任务的程序框架,可以用在各种场合,Gearman更偏向于任务分发功能.它的任务分布非常简单,简单得可以只需要用脚本即可完成. Gearman 分布式任务实现原理上只用到2个字段 ...

  9. windows phone 豆瓣api的封装

    利用周末的时候,重新封装一下豆瓣的api,就当是练手吧!其实现在网上好用的api很多,在这个demo里面基本上已经将整体框架搭建起来,本来想继续完善下去的.但是其实accesstoken的时候,一直拿 ...

  10. android开发中经常遇到的问题汇总

    大家都在为项目开发成功而喜悦,但可不知成功的路上是会经常出错的,下面是我碰到的一些错误集合! [错误信息] [2011-01-19 16:39:10 - ApiDemos] WARNING: Appl ...