Patchouli's Spell Cards


Time Limit: 7 Seconds      Memory Limit: 65536 KB


Patchouli Knowledge, the unmoving great library, is a magician who has settled down in the Scarlet Devil Mansion (紅魔館). Her specialty is elemental magic employing the seven elements fire, water, wood, metal, earth, sun, and moon. So she can cast different spell cards like Water Sign "Princess Undine", Moon Sign "Silent Selene" and Sun Sign "Royal Flare". In addition, she can combine the elements as well. So she can also cast high-level spell cards like Metal & Water Sign "Mercury Poison" and Fire, Water, Wood, Metal & Earth Sign "Philosopher's Stones" .

Assume that there are m different elements in total, each element has n different phase. Patchouli can use many different elements in a single spell card, as long as these elements have the same phases. The level of a spell card is determined by the number of different elements used in it. When Patchouli is going to have a fight, she will choose m different elements, each of which will have a random phase with the same probability. What's the probability that she can cast a spell card of which the level is no less than l, namely a spell card using at least l different elements.

Input

There are multiple cases. Each case contains three integers 1 ≤ m, n, l ≤ 100. Process to the end of file.

Output

For each case, output the probability as irreducible fraction. If it is impossible, output "mukyu~" instead.

Sample Input

7 6 5
7 7 7
7 8 9

Sample Output

187/15552
1/117649
mukyu~

题目意思:有m个元素,每个元素有n种相,现在从m个元素中,随机抽取每一种元素的一种相,每种相取到的概率相同,相同的相可以融合,融合的个数就为它的度,问你最大的度大于等于L的概率。

做法 :
JAVA大数
dp[n][m] 表示的意思是 前n种相,用了m个元素,符合最大的度小于L的方案个数。
dp[n][m] = sum(dp[n-1][m-k]*count[M-(m-k)][k])

import java.util.*;
import java.math.*;public class Main {static int maxn = 110;public static BigInteger[][] dp =new BigInteger[110][110];public static BigInteger[][] count = new BigInteger[110][110];public static void main(String[] args) {// TODO Auto-generated method stubfor(int i = 0; i < maxn; i++){count[i][0] = BigInteger.ONE;count[i][i] = BigInteger.ONE;for(int j = 1; j < i; j++){count[i][j] = count[i-1][j].add(count[i-1][j-1]);}}Scanner scan =  new Scanner(System.in);while(scan.hasNextInt()){int  m = scan.nextInt();int  n =  scan.nextInt();int  l = scan.nextInt();BigInteger nn = BigInteger.valueOf(n).subtract(BigInteger.ONE);BigInteger fm = BigInteger.valueOf(n).pow(m),fz = BigInteger.ZERO;if(l > m){System.out.println("mukyu~");}else{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 = 0; j <= m; j++){for(int k = 0;  k <= j&& k <l; k++){dp[i][j] = dp[i][j].add(dp[i-1][j-k].multiply(count[m-(j-k)][k]));   }}}fz = fm.subtract(dp[n][m]);BigInteger gcd = fz.gcd(fm);fz = fz.divide(gcd);fm = fm.divide(gcd);System.out.println(fz+"/"+fm);}}scan.close();}}
												

ZOJ3380- Patchouli's Spell Cards(概率DP+计数)相关推荐

  1. ZOJ 3380 Patchouli's Spell Cards( 概率DP)

    题意:用n个数填充m个位置,问有大于等于l个相同数字的概率. 这个题看了很多题解,大部分代码都是有点问题的,一开始dp的状态都是一样的.(具体见下) 思路:设dp[i][j] 为用前i个数填充j个位置 ...

  2. ZOJ 3380 Patchouli's Spell Cards 概率DP

    题意:给你m个位置,每个位置放一个数,区间为1-n,问你至少有L个位置是一样的数的概率,结果用分数表示 思路:这题我们从反向入手,dp[i][j]代表前i个数,放到j个位置,且没有L个或以上的位置有相 ...

  3. ZOJ-3380 Patchouli's Spell Cards(概率DP大数)

    Patchouli's Spell Cards http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3957 Time Limit:  ...

  4. zoj3380 Patchouli's Spell Cards

    Patchouli's Spell Cards Time Limit: 7 Seconds Memory Limit: 65536 KB Patchouli Knowledge, the unmovi ...

  5. ZOJ 3380 Patchouli's Spell Cards [基础DP+大数]

    Description Patchouli Knowledge, the unmoving great library, is a magician who has settled down in t ...

  6. ZOJ 3380 Patchouli's Spell Cards(DP,大数)

    转载请注明出处,谢谢http://blog.csdn.net/acm_cxlove/article/details/7854526       by---cxlove 题目:有m个位置,每个位置填入一 ...

  7. ZOJ3380 Patchouli's Spell Cards C++版(概率DP+大数)

    题意题解不说了,这里主要讲用C++大数 为了节省时间使用了进制压缩,使用long long数组,进制1e9,使进制的平方在long long范围内 用len记数字位数,保证无前导零,方便计算,最低位存 ...

  8. ZOJ 3380 Patchouli's Spell Cards(概率+大数)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3957 题意:m个位置,每个位置可以放n种数字(1-n).问至少有L个 ...

  9. ZOJ 3380 Patchouli's Spell Cards [基础概率DP+大数]

    Patchouli's Spell Cards Time Limit: 7 Seconds      Memory Limit: 65536 KB Patchouli Knowledge, the u ...

最新文章

  1. Linux中的简单文本处理
  2. C++_泛型编程与标准库(六)
  3. redis4.0.2集群搭建
  4. linux上传下载文件
  5. java IO流用法
  6. Java 二维数组的初始化
  7. 根目录访问php 404,nginx配置后只有根目录首页index.php能访问,其他页面404
  8. salt-api配置
  9. 迄今为止最详细的ubuntu无盘工作站安装指南
  10. GNS3 添加思科交换机
  11. 解决webSocket不兼容IE浏览器问题
  12. 从零开始学习CANoe(四)—— 设计panel
  13. 华为机考 叠积木 python (以及处理输入)
  14. 笔记本 GTX1050ti 安装win10 Ubuntu18.04 显卡问题
  15. c14cpm和dpm怎么换算_DPM7001液体闪烁计数器
  16. mysql5.5手册读书日记(2)
  17. iOS: UIScrollView的属性zooming
  18. LinkedIn领英账号达到一周添加好友邀请上限后怎么办?学会这四式三招,你也能解决LinkedIn领英账号添加好友的每周数量限制...
  19. 2021-08-02网关http或tcp收发等极简物联网通用json协议设计
  20. 多线程并发在电商系统下的追本溯源-电商实战

热门文章

  1. vscode python F12无法跳转定义的解决
  2. HihoCoder - 1272 买零食
  3. js base64编码格式图片另存为下载
  4. TLS 1.3科普——新特性与协议实现
  5. Linux下随机生成密码的命令总结
  6. 数据可视化大屏酷炫秘籍之前端开发者自己动手
  7. 深度学习(9) 计算机专业方面的期刊介绍
  8. openfeign调用异常:feign.FeignException: [405] during [GET]
  9. 威佐夫博弈 poj 1067
  10. mybatis-plus clickhouse支持分页