ZOJ3380-Patchouli & amp; #39; s Spell Cards (probability DP + count)

Source: Internet
Author: User

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 dedevil 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 likeWater Sign "Princess Undine",Moon Sign "Silent Selene"AndSun Sign "Royal Flare". In addition, she can combine the elements as well. So she can also cast high-level spell cards likeMetal & Water Sign "Mercury Poison"AndFire, Water, Wood, Metal & Earth Sign "Philosopher's Stones".

Assume that there areMDifferent elements in total, each element hasNDifferent phase. patchouli can use your 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 choZ success? Http://www.bkjia.com/kf/ware/vc/ "target =" _ blank "class =" keylink "> vc2UgPHZhcj5tPC92YXI + keys =" s the probability that she can cast a spell card of which the level is no lessL, Namely a spell card using at leastLDifferent 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 irequalcible fraction. If it is impossible, output "mukyu ~ "Instead.

Sample Input
7 6 57 7 77 8 9
Sample Output
187/155521/117649mukyu~
 
There are m elements, and each element has n phases. Now, from m elements, a phase of each element is randomly selected, and the probability of each element is the same, if the same number of elements can be merged, the number of fusion values is the degree of convergence. the maximum degree is the probability that the number is greater than or equal to L.
 
Practice:
JAVA large number
Dp [n] [m] indicates the first n phases. m elements are used to match the number of solutions with the maximum degree less than 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 
  
   

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.