poj 1633 Gladiators
来源:互联网 发布:linux系统修改ip地址 编辑:程序博客网 时间:2024/06/07 05:59
题目链接:http://poj.org/problem?id=1633
题目思路:用dp[i][j]记录有i个障碍,难度为j的方法数,它是从长度为i-1的情况加一个更高的障碍得到,由于只有高的才能放到低的两个平台之间,所以这时最高的还没有分开,对于前面的i-1个障碍相当于2*(i-1)个平台,由于最高只能插到相临两个平台之间,又由于插到递增平台之间难度不变,其余情况难度增加1,易得方程。
import java.math.BigInteger;import java.util.Scanner;public class Main {public static BigInteger[][] dp=new BigInteger[60][60];public static void init(){int i,j;for(i=0;i<=52;i++)for(j=0;j<=52;j++)dp[i][j]=BigInteger.ZERO;dp[1][1]=BigInteger.ONE;for(i=2;i<=52;i++)for(j=1;j<=i;j++){dp[i][j]=dp[i-1][j].multiply(BigInteger.valueOf(j)).add(dp[i-1][j-1].multiply(BigInteger.valueOf(2*i-j)));//System.out.println(" i "+i+" j "+j+" dp "+dp[i][j]);}}public static void main(String[] args) {int i,j,k,m,n;init();Scanner sc=new Scanner(System.in);n=sc.nextInt();for(i=0;i<n;i++){m=sc.nextInt();k=sc.nextInt();if(k>m)System.out.println(0);elseSystem.out.println(dp[m][k]);}}}
- poj 1633 Gladiators
- POJ 1633 Gladiators 笔记
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- 传智播客.Net培训基础加强班,推广期优惠已结束 3月31日起恢复原价1980元
- MySQL创建外键关联错误 - errno:150
- eclipse开发spring配置文件xml代码不提示的解决办法
- HDU3397 Sequence operation(线段树)
- Hibernate与各种数据库连接 配置
- poj 1633 Gladiators
- linux重要指令
- IOS开发之相册拾取器UIImagePickerController
- 实现任意地方拖拽
- MAC地址,IP地址,ARP,ARP欺骗---“白话”
- PS3模拟器尝试密码管理系统大写密码PBM
- Jquery 的google map 应用
- 宝石塔防:如果还有人过不去1337,俺来发个详细点儿的攻略吧
- 菜鸟学Python-输入输出、环境变量、print