题目链接:

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. centos6.2下安装redis和phpredis扩展,亲测好用

    安装redis: 下载:http://www.redis.io/download redis-2.6.2.tar.gz ]# tar -zxf redis-2.6.2.tar.gz ]# cd red ...

  2. C#获取本周周一的日期

    /// <summary> /// 获取本周的周一日期 /// </summary> /// <returns></returns> public st ...

  3. 配置Nginx服务

    一,安装之前准备1.nginx依赖: gcc openssl-devel pcre-devel zlib-devel    安装依赖:yum install gcc openssl-devel pcr ...

  4. 操作MySQL数据库

    向表中插入数据 insert 语句可以用来将一行或多行数据插到数据库表中, 使用的一般形式如下: insert [into] 表名 [(列名1, 列名2, 列名3, ...)] values (值1, ...

  5. ViewPager中GridView问题

    GridView 嵌套在ViewPager中问题. 1. GridView属性设置无法显示. 正常显示方式 <GridView android:padding="8dip" ...

  6. main函数的argc和argv

      int main(int argc, char const *argv[]) { printf("argc : %c\n",argc); printf(] ); printf( ...

  7. 配置php5.6的运行环境

    所需要的原材料:(提供链接) php-5.6.10-Win32-VC11-x86 (zip)(注意php版本分为了IIS版和Apache版) httpd-2.4.12-x86-r2(apache) ( ...

  8. SQL0294N 容器已在使用中。 SQLSTATE=42730

    在建立数据库后,建立表空间时,出现如下错误: CREATE TABLESPACE TABLESAPCE_NAME PAGESIZE 32K MANAGED BY SYSTEM USING ('E:\D ...

  9. 九度oj 1407 快速找出最小数

    原题链接:http://ac.jobdu.com/problem.php?pid=1407 线段树,区间更新,查询区间最小值. 注意区间更新,查询的时候,区间$\begin{align*}[L,R] ...

  10. 49.关于Quartus和ISE中ROM的初始化和仿真的一些小结

    最近在玩Altera的FPGA,当我用Quartus II自带的IP核生成ROM时,出现了各种问题,于是在网上各种查资料,终于解决了我的问题.这里做一下小结,方便自己日后查阅. Quartus II ...