zoukankan      html  css  js  c++  java
  • codeforce

    A. Playing with Dice
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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?

    Input

    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.

    Output

    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.

    Sample test(s)
    input
    2 5
    output
    3 0 3
    input
    2 4
    output
    2 1 3
    Note

    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|.

    做了一题水题,学校太坑,晚上想做场比赛都费劲,一直断电,一会睡觉吧。

     1 #include<stdio.h>
     2 int main(int argc, char const *argv[]) 
     3 {
     4     int a, b; 
     5     while(~scanf("%d%d", &a, &b))
     6     {
     7         if(!((a + b) % 2))
     8         {
     9             if(a == b)
    10             {
    11                 printf("0 6 0
    ");
    12             }
    13             else if(a < b)
    14             {
    15                 printf("%d ", (a + b)/2 - 1); 
    16                 printf("1 ");
    17                 printf("%d
    ", 6 - (a+b)/2); 
    18             }
    19             else
    20             {
    21                 printf("%d ", 6-(a+b)/2);
    22                 printf("1 "); 
    23                 printf("%d
    ", (a+b)/2 - 1);
    24             }
    25         }
    26         else
    27         {
    28             if(a < b)   
    29             {
    30                 printf("%d ", (a + b)/2); 
    31                 printf("0 "); 
    32                 printf("%d
    ", 6 - (a + b)/2);
    33             }
    34             else
    35             {
    36                 printf("%d ", 6-(a + b)/2); 
    37                 printf("0 ");
    38                 printf("%d
    ", (a+b)/2); 
    39             }
    40         }
    41     }
    42     return 0; 
    43 }
  • 相关阅读:
    迭代器生成器和协程函数
    装饰器
    对haproxy.conf文件的增删改查
    函数基础
    深入理解python字符编码
    python字符串列表字典常用方法
    委托的使用
    数据库连接
    输入输出流
    泛型集合的使用
  • 原文地址:https://www.cnblogs.com/anhuizhiye/p/3497014.html
Copyright © 2011-2022 走看看