Codeforces 9A-Die Roll(意甲冠军)
1 second
64 megabytes
standard input
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.
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
题意:三个人置筛子,如今给出前两个人的点数,仅仅要第三个人的点数大于等于前两个人的,第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;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
Codeforces 9A-Die Roll(意甲冠军)的更多相关文章
- Codeforces Beta Round #9 (Div. 2 Only) A. Die Roll 水题
A. Die Roll 题目连接: http://www.codeforces.com/contest/9/problem/A Description Yakko, Wakko and Dot, wo ...
- Codeforces 4A-Watermelon(意甲冠军)
A. Watermelon time limit per test 1 second memory limit per test 64 megabytes input standard input o ...
- Codeforces 10C Digital Root 法冠军
主题链接:点击打开链接 #include<stdio.h> #include<iostream> #include<string.h> #include<se ...
- 【CodeForces】9A-Die Roll
目录 Question Solution 解法1 解法2 Question 三个人掷骰子,前两个人的得分分别是Y和W,问第三个人胜利的概率(第三个人得分不小于Y.W)?结果输出格式为\(A/B\),如 ...
- Codeforces 475C Kamal-ol-molk's Painting 模拟
主题链接:点击打开链接 意甲冠军:特定n*m矩阵 X代表色 .代表无色 随着x*y形刷子去涂色. 刷子每次能够→或↓移动随意步. 若可以染出给定的矩阵,则输出最小的刷子的面积 若不能输出-1 思路: ...
- Codeforces 39E What Has Dirichlet Got to Do with That? 游戏+内存搜索
主题链接:点击打开链接 意甲冠军: 特定 a一箱 b球 不变n (球和箱子都不尽相同,样的物品) 设 way = 把b个球放到a个箱子中的方法数, 若way >= n则游戏结束 有2个人玩游戏. ...
- CodeForces 484B Maximum Value
意甲冠军: a序列n(2*10^5)数字 问道a[i]>=a[j]如果是 a[i]%a[j]最大值是多少 思路: 感觉是一道挺乱来的题-- 我们能够将ans表示为a[i]-k*a[j] 这 ...
- Codeforces Round #264 (Div. 2) C Gargari and Bishops 【暴力】
称号: 意甲冠军:给定一个矩阵,每格我们有一个数,然后把两个大象,我希望能够吃的对角线上的所有数字.我问两个最大的大象可以吃值. 分析:这种想法是暴力的主题,计算出每一格放象的话能得到多少钱,然后求出 ...
- CodeForces 484A Bits
意甲冠军: 10000询价 每次查询输入L和R(10^18) 在区间的二进制输出指示1大多数数字 1个数同样输出最小的 思路: YY一下 认为后几位全是1的时候能保证1的个数多 那么怎样构造 ...
随机推荐
- Codeforces 474 F. Ant colony
线段树求某一段的GCD..... F. Ant colony time limit per test 1 second memory limit per test 256 megabytes inpu ...
- CV和Resume的区别(转)
常常有人把CV和Resume混起来称为“简历”,其实精确而言,CV应该是“履历”,Resume才是简历.Resume概述了有关的教育准备和经历,是对经验技能的摘要:curriculum vitae则集 ...
- 无法删除 C_PAN.GHO: 访问被拒绝 解决办法
右击“C-PAN.GHO",属性->安全(如果没有安全选项卡,可以在工具->文件夹选项->查看中将”使用简单头文件共享“前的对勾去掉),这时”添加“和”删除“按钮应该是不可 ...
- C# 计算字符串/文件的哈希值(MD5、SHA)
原文 C# 计算字符串的哈希值(MD5.SHA) 已做修改 一.关于本文 本文中是一个类库,包括下面几个函数: /// 1)计算32位MD5码(大小写):Hash_MD5_32 /// 2)计算16位 ...
- SQLServer 复制中移除和加入公布而不初始化全部项目
-- 若提前"禁止架构更改".新增的列不会自己主动加入大公布.此时应使用 sp_articlecolumn 加入列 EXEC sp_changepublication @publi ...
- 2014ACM/ICPC亚洲区西安站 F题 color (组合数学,容斥原理)
题目链接:传送门 题意: n个格子排成一行.我们有m种颜色.能够给这些格子涂色,保证相邻的格子的颜色不同 问,最后恰好使用了k种颜色的方案数. 分析: 看完题目描写叙述之后立刻想到了一个公式 :C(m ...
- C库函数标准编程之fscanf()函数解读及其实验
函数功能 fscanf()函数用于从参数stream的文件流中读取format格式的内容,然后存放到...所指定的变量中去.字符串以空格或换行符结束(实验1中会对它进一步说明) 函数格式 字符格式说明 ...
- JsonCpp Documentation
JsonCpp - JSON data format manipulation library JsonCpp Documentation 0.6.0-rc2 Introduction JSON (J ...
- 浅析ArrayList,LinkedList的执行效率
以前见过很多文章说这两个东西,感觉自己还是没有深入理解,今天看了书明白一些,在此提出来和大家共同探讨: 面试的时候(基础)一般会问你使用过LinkedList或者ArrayList没有,简单的回答有或 ...
- WPF换肤之六:酷炫的时区浏览小精灵
原文:WPF换肤之六:酷炫的时区浏览小精灵 由于工作需要,经常要查看到不同地区的 当前时间,以前总是对照着时区表来进行加减运算,现在有了这个小工具以后,感觉省心了不少.下面是软件的截图: 效果图赏析 ...