codeforces9A

Die Roll

 CodeForces - 9A 

Yakko,Wakko和Dot,世界著名的狂欢三宝,哈哈,不知道你是否看过这个动画片。
某一天,过年了,他们决定暂定卡通表演,并去某些地方旅游一下。Yakko梦想去宾夕法尼亚州,那是他的故乡。Wakko想过塔斯马尼亚,它的海滩,阳光和大海。Dot选择去特兰西瓦尼亚,她认为这个地方最神秘莫测。
 
但他们非常遗憾,由于休假的时间很短,所以只能去其中一个地方。聪明的Yakko,有了一个想法:拿一个六面分别写着1-6数字的骰子,每个人轮流掷骰子,谁的点数大,就去谁想要去的地方。
 
Yakko掷出了y点,Wakko掷出了w点,现在轮到Dot掷了,但她并没有急着。Dot想知道她有多少机会去参观特兰西瓦尼亚。
 
由于,Yakko和Wakko是真正的绅士,他们决定如果Dot和他们的点数一样,就让她获胜。

Input

输入只有一行两个正整数,分别表示y和w。

Output

输出Dot获胜的可能性,用不能化简的分数表示,如果可能性是0,就输出“0/1"(不包含双引号),如果可能性是100%,就输出“1/1"(不包含双引号)。

Sample Input

4 2

Sample Output

1/2

Hint

Dot会去特兰西瓦尼亚,如果她是幸运的滚4,5或6分。

sol:小学奥数吧。获胜的概率就是7-max(Y,W) / 6

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0;
    bool f=0;
    char ch=' ';
    while(!isdigit(ch))
    {
        f|=(ch=='-'); ch=getchar();
    }
    while(isdigit(ch))
    {
        s=(s<<3)+(s<<1)+(ch^48); ch=getchar();
    }
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0)
    {
        putchar('-'); x=-x;
    }
    if(x<10)
    {
        putchar(x+'0'); return;
    }
    write(x/10);
    putchar((x%10)+'0');
    return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
inline int gcd(int x,int y)
{
    return (!y)?(x):(gcd(y,x%y));
}
int main()
{
    int a,b,x,gg;
    R(a); R(b);
    x=6-max(a,b)+1;
    gg=gcd(x,6);
    printf("%d/%d\n",x/gg,6/gg);
    return 0;
}
/*
input
4 2
output
1/2
*/
View Code

猜你喜欢

转载自www.cnblogs.com/gaojunonly1/p/10585197.html
今日推荐