ZOJ 3380 Patchouli's Spell Cards (概率dp)
来源:互联网 发布:网络系统威胁 网络传输 编辑:程序博客网 时间:2024/05/22 13:08
题意:有m种元素,每种元素可以配n种phase之一;相同phase的元素可以组成一张spell card,card的等级为元素的种数, 问m种元素随机生成的card有多少概率使他的等级至少为l
dp[i][j]为用前i种phase生成i种元素有多少种情况
dp[i][j] = dp[i][j-k] * C[m-j+k][k] ( k >= 0 && k <= j && k < l )
意思是用第i种phase去生成k个元素
则答案为 ( n^m - dp[1~n][m] ) / ( n^m );
import java.math.*;import java.io.*;import java.util.*;public class Main {static BigInteger[][] dp = new BigInteger[111][111];static BigInteger[][] C = new BigInteger[111][111];static public void main ( String [] args ) {Scanner cin = new Scanner( System.in );for( int i = 0;i < 110; i++ ) {C[i][0] = C[i][i] = BigInteger.ONE;for( int j = 1; j < i; ++j ) C[i][j] = C[i-1][j-1].add( C[i-1][j] );}int n, m, l;while( cin.hasNext() ) {m = cin.nextInt();n = cin.nextInt();l = cin.nextInt();if ( l > m ) {System.out.println( "mukyu~");continue;}for( int i = 0; i <= n; ++i )for( int j = 0; j <= m; ++j )dp[i][j] = BigInteger.ZERO;dp[0][0] = BigInteger.ONE;for( int i = 1; i <= n; ++i ) for( int j = 1; j <= m; ++j ) {dp[i][j] = dp[i][j].add( dp[i-1][j] );for( int k = 1; k <= j && k < l; ++k ) dp[i][j] = dp[i][j].add( dp[i-1][j-k].multiply( C[m-j+k][k]) );}BigInteger ans = BigInteger.ZERO;for( int i = 1; i <= n; ++i ) ans = ans.add( dp[i][m] );//System.out.println( ans );BigInteger tot = BigInteger.valueOf( n ).pow( m );ans = tot.subtract( ans );BigInteger tmp = ans.gcd( tot );System.out.println( ans.divide( tmp ) +"/" + tot.divide( tmp ) );}}}
0 0
- ZOJ 3380 Patchouli's Spell Cards (概率dp)
- ZOJ 3380 Patchouli's Spell Cards(概率DP)
- ZOJ-3380 Patchouli's Spell Cards(概率DP&&大数)
- ZOJ 3380 Patchouli's Spell Cards(概率DP)
- ZOJ 3380 Patchouli's Spell Cards 概率DP
- Zoj 3380 Patchouli's Spell Cards (概率dp)
- ZOJ 3380 Patchouli's Spell Cards( 概率DP)
- ZOJ 3380 Patchouli's Spell Cards 概率DP
- ZOJ 3380 Patchouli's Spell Cards [基础概率DP+大数]
- ZOJ 3380 Patchouli's Spell Cards(DP,大数)
- ZOJ 3380 Patchouli's Spell Cards [基础DP+大数]
- ZOJ3380- Patchouli's Spell Cards(概率DP+计数)
- zoj3380 Patchouli's Spell Cards
- ★ZOJ 3380 Patchouli's Spell Cards 详细题解 (递推+组合数求方案数)
- BNU Cards 概率dp
- ZOJ--3822(概率dp)
- zoj 2852 Deck of Cards扑克牌(三维dp)
- ZOJ 3551 Bloodsucker (概率DP)
- opengl中glblendfunc用法
- IndentationError:expected an indented block错误解读
- Codeforces Round #274 (Div. 2) C. Exams
- addPosition方法的源码
- 互联网是一个很好的工具
- ZOJ 3380 Patchouli's Spell Cards (概率dp)
- ZOJ2016 POJ1386(有向图的欧拉路判断)
- [go语言]同时上传表单字段和文件
- hdu 2149 Public Sale(博弈)
- UVa 1533 - Moving Pegs (隐式图搜索 + 状态压缩)
- Unity3D如何使用脚本实现跳跃的效果
- ffmpeg的编译大全(包括 ffmpeg for android)
- 动态生成mybatis的xml文件,其中的sql语句生成
- qq侧滑