Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll 水题
2016-04-20 15:53
2791 查看
A. Die Roll
题目连接:
http://www.codeforces.com/contest/9/problem/ADescription
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 Input
4 2Sample Output
1/2Hint
题意
有三个人在玩掷骰子,然后第一个人扔了个A,第二个人扔了个B现在问你有多大的概率能够赢过这两个人,平局也算自己赢。
题解:
水题啦要求化简成为最简单的分数,这个用gcd就好了
代码
#include<bits/stdc++.h> using namespace std; int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } int main() { int a,b; scanf("%d%d",&a,&b); a=max(a,b); printf("%d/%d",(7-a)/gcd(7-a,6),6/gcd(7-a,6)); }
相关文章推荐
- salesforce 零基础学习(十六)Validation Rules & Date/time
- 构建之法阅读笔记02
- Autofac 组件、服务、自动装配 《第二篇》
- opencv--detectMultiScale: output detection score
- bzoj 4373: 算术天才⑨与等差数列
- JavaScript表单填写时,数据索引筛选自动填写功能效果
- MongoDB设置环境变量与设置成Windows服务
- 常见通信协议HTTP、TCP、UDP的简单介绍
- 常见通信协议HTTP、TCP、UDP的简单介绍
- TestNG 学习总结 - 测试过程(五)
- HashTable 和 HashSet 的源码分析
- GCD 第三篇 dispatch_group
- linux下添加PATH环境变量
- 从此不求人:自主研发一套PHP前端开发框架(26)
- 依赖注入框架Autofac的简单使用
- 机器学习/数据挖掘/十大经典算法总结
- js中namespace命名空间模式
- SQLMAP常用选项
- 桌面widget详解(四)——桌面音乐播放器(实战)
- 【转】WEB应用中的SESSION知多少?