CF 9A. Die Roll
来源:互联网 发布:15年广东省的经济数据 编辑:程序博客网 时间:2024/05/01 11:55
Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.
But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.
Yakko thrown a die and got Y points, Wakko — W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.
It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.
The only line of the input file contains two natural numbers Y and W — the results of Yakko's and Wakko's die rolls.
Output the required probability in the form of irreducible fraction in format «A/B», where A — the numerator, and B — the denominator. If the required probability equals to zero, output «0/1». If the required probability equals to 1, output «1/1».
4 2
1/2
Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points.
这个题目就是简单的概率题目,输入两个数Y和W,但是第三个人赢的几率为>=max(Y,W),然后求概率:
#include <iostream>using namespace std;int main(){ int n,m,max,flag,sum=6; cin>>n>>m; flag=0; if(n>=m) max=n; else max=m; for(int i=max; i<=6; i++) { flag++; } if(flag) { for(int i=2; i<=6; i++) if(flag%i==0&&sum%i==0) { flag=flag/i,sum=sum/i; } cout<<flag<<"/"<<sum<<endl; } else cout<<"0/1"<<endl; return 0;}
- CF 9A. Die Roll
- CF 9A Die Roll
- cf 9a Die Roll
- 9A - Die Roll
- CodeForces 9A - Die Roll
- CodeForces 9A Die Roll
- CodeForces - 9A A. Die Roll
- 【水枚举】#9 A. Die Roll
- Codeforces 9A-Die Roll(题意)
- A. Die Roll
- A. Die Roll
- codeforces-9A-A. Die Roll ( C && GCD )
- CodeForces 9A Die Roll(简单题)
- Die Roll
- Die ROll
- codeforces_9A Die Roll
- ZOJ 1208 roll the die
- ZOJ-1208 Roll the Die!
- java--泛型
- 2013年算法组题目2
- 二叉查找树的实现
- linux内核系统调用和标准C库函数的关系分析
- [LeetCode] Plus One
- CF 9A. Die Roll
- Java数组与内存控制
- GStreamer播放教程02——字幕管理
- seam中的<s:validateEquality>标签
- java集合类总结
- 利用Java编写简单的WebService实例
- java文件复制
- RTB, DSP, AdExchange知识点汇总
- Java可以做什么及可以给我们带来什么?