9A - Die Roll

A. Die Roll

time limit per test1 second
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.
Input
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
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».
Examples
Input
Copy
4 2
Output
Copy
1/2
Note
Dot will go to Transylvania, if she is lucky to roll 4, 5 or 6 points.
题意:摇色子,Y和W先摇,但D与w或Y中最大的比较,如果相同的话,D赢。
题解:先找出Y和D中最大的那一个,6-max为D能赢的范围,如果D为偶数,总可能与D均除于2,接着如果“总可能”能整除D,则D/总可能。

#include
using namespace std;
int main()
{
 int a,b,k;
 cin>>a>>b;
 a=max(a,b);
 b=(6-a)+1;
 a=6;
 if(b%2==0)
 {
  b=b/2;
  a=6/2;
 }
 if(a%b==0)
 {
  a=a/b;
  b=1;
 }
 cout<

你可能感兴趣的:(9A - Die Roll)