HDOJ 2049 不容易系列之(4)——考新郎
来源:互联网 发布:java读取csv文件内容 编辑:程序博客网 时间:2024/06/02 23:45
http://acm.hdu.edu.cn/showproblem.php?pid=2049
这一题和上一题的思路差不多,但是这一题需要对N和M排列,即在N对中选M对进行错排。
import java.util.Scanner;public class Main { public static void main(String[] args) { long[] d=new long[25]; long[] c=new long[25]; d[1]=0;c[1]=1;c[0]=1; d[2]=1;c[2]=2; for(int i=3;i<21;i++){ d[i]=(i-1)*(d[i-1]+d[i-2]); c[i]=c[i-1]*i; } Scanner sc=new Scanner(System.in); int n=sc.nextInt(); while(n-->0){ int a=sc.nextInt(); int b=sc.nextInt(); long x=c[a]/(c[b]*c[a-b]); System.out.println(x*d[b]); } }}
0 0
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- HDOJ 2049 不容易系列之(4)——考新郎
- hdoj-2049-不容易系列之(4)——考新郎
- hdoj-【2049 不容易系列之(4)——考新郎】
- hdoj 2049 不容易系列之(4)——考新郎
- 错排问题系列之 不容易系列之(4)——考新郎 hdoj 2049
- HDOJ, 杭电2049, 不容易系列之(4)——考新郎。。。组合加错排。
- HDOJ 题目2049 不容易系列之(4)——考新郎(部分错排)
- hdoj 2049 不容易系列之(4)——考新郎 【全错位排列】【组合数】
- hdoj.2049 不容易系列之(4)——考新郎 20140805
- HDOJ 不容易系列之(4)——考新郎 2049(错排)
- IOS 发布应用程序到App Store
- dom4j-Quick Start Guide
- 码农小汪-剑指Offer之18-包含min函数的栈
- 第4周项目5-用递归方法求解4
- CF_5A_ChatServer'sOutgoingTraffic
- HDOJ 2049 不容易系列之(4)——考新郎
- 开发者需要知道的iOS 8 SDK新特性
- 关于String,StringBuffer与StringBuilder
- Java学习_多线程
- IOS学习之——面试问题集锦
- 三角形三边
- 深入理解ThreadLocal
- iOS 7 新特性:视图控制器切换API
- Django + Apache + wsgi配置和环境搭建(ubuntu)