24h購物| | PChome| 登入
2013-12-05 15:43:24| 人氣1,913| 回應0 | 上一篇 | 下一篇

[UVA][Easy] 12646 - Zero or One

推薦 0 收藏 0 轉貼0 訂閱站台

Everyone probably knows the game

ZeroorOne

(in some regions in Brazil also known as

Twoor

One

), used to determine a winner among three or more players. For those unfamiliar, the game works

as follows. Each player chooses a value between zero or one; prompted by a command (usually one of

the contestants announces \Zero or... One!"), all participants show the value chosen using a hand: if

the value chosen is one, the contestant shows a hand with an extended index
nger; if the value chosen

is zero, the contestant shows a hand with all
ngers closed. The winner is the one who has chosen

a value di
erent from all others. If there is no player with a value di
erent from all others (e.g. all

players choose zero, or some players choose zero and some players choose one), there is no winner.

Alice, Bob and Clara are great friends and play Zerinho all the time: to determine who will buy

popcorn during the movie session, who will enter the swimming pool
rst, etc.. They play so much that

they decided make a plugin to play Zerinho on Facebook. But since the don't know how to program

computers, they divided the tasks among friends who do know, including you.

Given the three values chosen by Alice, Bob and Clara, each value zero or one, write a program

that determines if there is a winner, and in that case determines who is the winner.

Input

The input contains several test cases. Each test case contains a single line, with three integers

A

,

B

and

C

, indicating respectively the values chosen by Alice, Beto and Clara.

Output

For each test case your program must output a single line, containing a single character. If Alice is the

winner the character must be `

A

', if Beto is the winner the character must be `

B

', if Clara is the winner

the character must be `

C

', and if there is no winner the character must be `

*

' (asterisc).

Restrictions

A;B;C

2f

0

;

1

g

SampleInput

1 1 0

0 0 0

1 0 0

SampleOutput

C

*

A

 





#include <stdio.h>

int main() {
    int A, B, C;
    while(scanf("%d %d %d", &A, &B, &C) == 3) {
        int c[2] = {}, v[2] = {};
        c[A]++, c[B]++, c[C]++;
        v[A] = 0, v[B] = 1, v[C] = 2;
        if(c[0] == 3 || c[1] == 3)
            puts("*");
        else
            printf("%c\n", c[0] == 1 ? v[0]+'A' : v[1]+'A');
    }
    return 0;
}

台長: Morris
人氣(1,913) | 回應(0)| 推薦 (0)| 收藏 (0)| 轉寄
全站分類: 教育學習(進修、留學、學術研究、教育概況) | 個人分類: UVA |
此分類下一篇:[UVA][Easy] 12650 - Dangerous Dive
此分類上一篇:[UVA][外接圓] 10439 - Temple of Dune

是 (若未登入"個人新聞台帳號"則看不到回覆唷!)
* 請輸入識別碼:
請輸入圖片中算式的結果(可能為0) 
(有*為必填)
TOP
詳全文