1 1 1
1/3
解题思路,一个是 贝叶斯公式和 最大公约数的问题
(图是盗的:原连接_ https://blog.csdn.net/hy971216/article/details/78633375 )

Java 代码实现
1 import java.math.BigInteger; 2 import java.util.Scanner; 3 4 public class Main { 5 6 public static BigInteger getPow(BigInteger a,BigInteger n){ 7 BigInteger res = new BigInteger("1"); 8 for(int i=1;i<=n.intValue();i++){ 9 res = res.multiply(a); 10 } 11 return res; 12 } 13 14 public static void main(String[] args) { 15 16 Scanner cin = new Scanner(System.in); 17 while(cin.hasNext()){ 18 BigInteger m = new BigInteger(cin.next()); 19 BigInteger n = new BigInteger(cin.next()); 20 BigInteger k = new BigInteger(cin.next()); 21 22 BigInteger res = m.add(n.multiply(getPow(new BigInteger("2"), k))); 23 BigInteger gcd = res.gcd(m); 24 System.out.println(m.divide(gcd)+"/"+res.divide(gcd)); 25 } 26 27 } 28 29 }
《内蒙古自治区第十二届大学生程序设计竞赛试题_D: 正品的概率》
原文:https://www.cnblogs.com/kangxinxin/p/10794224.html