日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

zoj3380 Patchouli's Spell Cards

發布時間:2024/3/12 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zoj3380 Patchouli's Spell Cards 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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~ 當l>m明顯無解,l>m/2,可直接用組合數求出,當l<=m/2,這里就不能用組合數求了,因為,這里會有重復,用dp[i][j]表示前i個數字,第j位,滿足某個數字小于l的個數,那么我們可以得出dp[i][j]=dp[i][j-k]c[m-j+k][k],也就是第i個數字,可以放1-k個位置,這樣就可以得出答案了! import java.math.BigInteger; import java.util.Scanner; public class Main {public static void main(String[] args) {Scanner a=new Scanner(System.in);int M=150;BigInteger dp[][]=new BigInteger[150][150];BigInteger an[][]=new BigInteger[150][150];BigInteger one ,zero;one=BigInteger.ONE;zero=BigInteger.ZERO;for(int i=0;i<120;i++){dp[i][i]=dp[i][0]=dp[0][i]=one;for(int j=1;j<i;j++){dp[i][j]=dp[i-1][j-1].add(dp[i-1][j]);}}while(a.hasNext()){int m,n,l;BigInteger ans,nn,mm,ll,all,gcd;m=a.nextInt();n=a.nextInt();l=a.nextInt();nn=BigInteger.valueOf(n);mm=BigInteger.valueOf(m);ll=BigInteger.valueOf(l);ans=nn.pow(m);if(l>m){System.out.print("mukyu~\n");continue;}if(l>m/2){all=zero;for(int i=l;i<=m;i++){all=all.add(dp[m][i].multiply(BigInteger.valueOf(n-1).pow(m-i)));}all=BigInteger.valueOf(n).multiply(all);gcd=ans.gcd(all);System.out.println(all.divide(gcd)+"/"+ans.divide(gcd));continue;}for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)an[i][j]=zero;an[0][0]=one; for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){for(int k=0;k<=j&&k<l;k++){an[i][j]=an[i][j].add(an[i-1][j-k].multiply(dp[m-j+k][k]));}}all=zero;for(int i=1;i<=n;i++){all=all.add(an[i][m]);}all=ans.subtract(all);gcd=ans.gcd(all);System.out.println(all.divide(gcd)+"/"+ans.divide(gcd));}}}

總結

以上是生活随笔為你收集整理的zoj3380 Patchouli's Spell Cards的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。