3620 - C
黑黑、白白、酷酷在一起玩游戏,他们玩的是有六个面的骰子, 谁大算谁赢。黑黑和白白先扔,扔出了两个数a和b,由于黑黑和白白都非常的绅士,所以如果酷酷扔出了跟他们最大的数字一样的数字,算酷酷赢。
Input
一行两个整数,a和b.
Output
输出一个分数,代表酷酷赢的概率,如果得到的结果是1,输出1/1,如果得到的结果是0,输出0/1.
Examples
Input
6 2
Output
1/6
Solution C
#include <stdio.h> int max(int a,int b) { return a > b ? a : b; } int main() { int a,b; while(~scanf("%d%d",&a,&b)) { int c; c = 6 - max(a,b); if(c == 0) printf("1/6\n"); else if(c == 1) printf("1/3\n"); else if(c == 2) printf("1/2\n"); else if(c == 3) printf("2/3\n"); else if(c == 4) printf("5/6\n"); else printf("1/1\n"); } }
Solution C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cctype> #include<cmath> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<bitset> #include<queue> #include<stack> #include<list> #include<map> #include<set> #define TEST #define LL long long #define Mt(f, x) memset(f, x, sizeof(f)); #define rep(i, s, e) for(int i = (s); i <= (e); ++i) #ifdef TEST #define See(a) cout << #a << " = " << a << endl; #define See2(a, b) cout << #a << " = " << a << ' ' << #b << " = " << b << endl; #define debug(a, s, e) rep(_i, s, e) {cout << a[_i] << ' ';} cout << endl; #define debug2(a, s, e, ss, ee) rep(i_, s, e) {debug(a[i_], ss, ee)} #else #define See(a) #define See2(a, b) #define debug(a, s, e) #define debug2(a, s, e, ss, ee) #endif // TEST const int MAX = 2e9; const int MIN = -2e9; const double eps = 1e-8; const double PI = acos(-1.0); using namespace std; int gcd(int a, int b) { return b ? gcd(b, a % b) : a; } int main() { int a, b; // freopen("in.txt", "r", stdin); // freopen("out.txt", "w", stdout); while(~scanf("%d%d", &a, &b)) { int c = max(a, b); int fz = 6 - c + 1; int fm = 6; int g = gcd(fz, fm); fz /= g; fm /= g; printf("%d/%d\n", fz, fm); } return 0; }