HDOJ 1133 Buy the Ticket
2015-01-20 10:10
357 查看
题意:有m个带50元的人和n个带100元的人,开始时收银台没有钱,每张票卖50,并且结束时没有50元,求有多少种排队的顺序
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1133
思路:可以求出公式ans=(m+n)!*(m-n+1)/(m+1)
注意点:唔
以下为AC代码:
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1133
思路:可以求出公式ans=(m+n)!*(m-n+1)/(m+1)
注意点:唔
以下为AC代码:
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
12742559 | 2015-01-20 10:09:55 | Accepted | 1133 | 312MS | 9744K | 823 B | Java | luminous11 |
import java.io.*; import java.math.*; import java.util.*; public class Main{ public static void main(String args[]){ Scanner cin = new Scanner(System.in); int ncase = 0; while ( cin.hasNext() ){ ncase ++; BigInteger a = new BigInteger("1"); int c = cin.nextInt(); int b = cin.nextInt(); if ( c == 0 && b == 0 ){ break; } System.out.printf("Test #%d:%n", ncase); if ( c < b ){ System.out.println("0"); continue; } for ( int i = 1; i <= c+b; i ++ ){ BigInteger tmp = new BigInteger(((Integer)i).toString()); a = a.multiply(tmp); } BigInteger tmp = new BigInteger(((Integer)(c-b+1)).toString()); a = a.multiply(tmp); tmp = new BigInteger(((Integer)(c+1)).toString()); a = a.divide(tmp); System.out.println(a); } } }
相关文章推荐
- HDOJ-1133 Buy the Ticket[卡特兰数]
- hdoj 1133 Buy the Ticket 【DP】【java】【水】
- HDOJ_ 1133 Buy the Ticket
- hdoj 1133 Buy the Ticket 【卡特兰】
- HDOJ HDU 1133 Buy the Ticket ACM 1133 IN HDU
- HDOJ 1133 Buy the Ticket 简单解题报告
- HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)
- HDOJ/HDU 1133 Buy the Ticket(数论~卡特兰数~大数~)
- hdoj Buy the Ticket 1133 (排列组合题)
- ACM--哈利波特电影票--HDOJ 1133--Buy the Ticket--递推
- HDOJ 1133 Buy the Ticket(高精度卡特兰数变形)
- 杭电1133-Buy the Ticket
- hdu 1133 Buy the Ticket
- hdu 1133 Buy the Ticket
- HDU 1133 Buy the Ticket
- 1133-Buy the Ticket
- HDOJ 1133 Buy the tickets!
- hdu 1133 Buy the Ticket(卡特兰数 + 高精度)
- HDU 1133 - Buy the Ticket 【动态规划+组合 ~递推 偶遇 卡特兰】
- HDOJ HDU 1133 Buy the Ticket