Codeforces Round #222 (Div. 2)---A. Playing with Dice
来源:互联网 发布:一个矩阵的协方差矩阵 编辑:程序博客网 时间:2024/06/07 01:49
Two players are playing a game. First each of them writes an integer from 1 to 6, and then a dice is thrown. The player whose written number got closer to the number on the dice wins. If both payers have the same difference, it's a draw.
The first player wrote number a, the second player wrote number b. How many ways to throw a dice are there, at which the first player wins, or there is a draw, or the second player wins?
The single line contains two integers a and b (1 ≤ a, b ≤ 6) — the numbers written on the paper by the first and second player, correspondingly.
Print three integers: the number of ways to throw the dice at which the first player wins, the game ends with a draw or the second player wins, correspondingly.
2 5
3 0 3
2 4
2 1 3
The dice is a standard cube-shaped six-sided object with each side containing a number from 1 to 6, and where all numbers on all sides are distinct.
You can assume that number a is closer to number x than number b, if |a - x| < |b - x|.
解题思路:暴力。直接枚举所有的x的位置,分别判断即可。
AC代码:
#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){//freopen("in.txt", "r", stdin);int a, b, x, t, tt, ttt;while(scanf("%d%d", &a, &b)==2){t = tt = ttt = 0;for(x=1; x<=6; x++){if(abs(a-x) < abs(b-x)) t ++;else if(abs(a-x) > abs(b-x)) ttt ++;else tt ++;}printf("%d %d %d\n", t, tt, ttt);}return 0;}
- Codeforces Round #222 (Div. 2)---A. Playing with Dice
- Codeforces Round #296 (Div. 2) A. Playing with Paper
- Codeforces Round #296 (Div. 2) -----A. Playing with Paper
- codeforces--12.29--A. Playing with Dice
- codeforces 378A Playing with Dice
- codeforces Playing with Dice
- A. Playing with Dice
- A. Playing with Paper( Codeforces Round #296 (Div. 2) 水题)
- CodeForces 378A Playing with Dice(水题)
- Codeforces Round #139 (Div. 2) A. Dice Tower
- Codeforces Round #298 (Div. 2) C. Polycarpus' Dice(数学)
- Codeforces Round #298 (Div. 2) C Polycarpus' Dice
- Codeforces Round #298 (Div. 2) -- Polycarpus' Dice (数学推理)
- Codeforces Round #298 (Div. 2) C. Polycarpus' Dice(思路)
- Codeforces Round #133 (Div. 2) A. Tiling with Hexagons(数学)
- Codeforces Round #258 (Div. 2)1A Game With Sticks
- Codeforces Round #258 (Div. 2/A)/Codeforces451A_Game With Sticks
- Codeforces Round #258 (Div. 2) A. Game With Sticks
- IOS8 点击UIScollView上的按钮时无法滑动的解决方法
- 离线安装CDH 5
- Android动画之Interpolator和AnimationSet(三)
- 编辑框工具类 类名称:EditText_U
- 认识云计算
- Codeforces Round #222 (Div. 2)---A. Playing with Dice
- * 类描述:字符串工具类 类名称:String_U
- python核心模块之pickle和cPickle讲解
- JAVA第二课(运算符)
- 浅谈软件测试团队规范建设
- Cucumber-Lemonade Chiller
- 撒旦撒打算的发
- Azure CentOS FIO
- linux命令今天用到cp命令记录下