Codeforces 9A-Die Roll(意甲冠军)
2015-10-24 19:20
309 查看
A. Die Roll
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard 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».
Sample test(s)
input
output
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard 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».
Sample test(s)
input
4 2
output
1/2
题意:三个人置筛子,如今给出前两个人的点数,仅仅要第三个人的点数大于等于前两个人的,第3个则胜出,求第三个人胜出的概率,假设是0 输出0/1 假设是1
输出1/1 否则 化简后按分数模式输出 事实上细致一想第三个不可能输的。。。 即使前两人点数都为6 第三个人胜出的概率也有1/6
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <vector> using namespace std; #define LL long long int gcd(int a,int b) { if(b==0) return a; else return gcd(b,a%b); } int main() { int x,y; while(cin>>x>>y) { int t=6-max(x,y)+1; if(t==6) { puts("1/1"); continue; } printf("%d/%d\n",t/gcd(t,6),6/gcd(t,6)); } return 0; }
相关文章推荐
- [JCWC2005]Draw
- 写一个Windows上的守护进程(1)开篇
- 【PAT】1102. Invert a Binary Tree (25)
- 黑马程序员——————泛型的使用与Map的初步学习
- Java基础(3)----选择与循环语句
- UML之用例图
- Java基础程序设计---数据类型
- [深入理解Java虚拟机]第七章 类加载的过程
- linux下ElasticSearch安装部署
- 2015-2016 ACM-ICPC, NEERC, Moscow Subregional Contest A题:Anagrams [打表/规律题]
- 关于javascript中this的理解
- className.class.getResourceAsStream()与ClassLoader.getSystemResourceAsStream() 的区别
- C++对象模型——默认构造函数的合成
- Java概述及JDK的安装
- C++的几个知识点
- 转发和重定向 方法的使用
- ACM学习历程—HDU 5072 Coprime(容斥原理)
- VC++ 在控件上写字时 字体的设置技巧
- (NO.00001)iOS游戏SpeedBoy Lite成形记(十五)
- hdu5495