-
Notifications
You must be signed in to change notification settings - Fork 2
/
2480.c
76 lines (67 loc) · 1.87 KB
/
2480.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// [ 백준 ] 2480번: 주사위 세 개
#include <stdio.h>
enum Dice { ONE = 1, TWO, THREE };
int ONE_DICE_SAME_MULTIPLY = 100;
int TWO_DICES_SAME_MULTIPLY = 100;
int TWO_DICES_SAME_PRIZE = 1000;
int THREE_DICES_SAME_MULTIPLY = 1000;
int THREE_DICES_SAME_PRIZE = 10000;
int GetSameDice(int first, int second, int third)
{
if (first == second) {
return first;
}
if (second == third) {
return second;
}
return third;
}
int GetMaximumDice(int first, int second, int third)
{
if (first >= second && first >= third) {
return first;
}
if (second >= first && second >= third) {
return second;
}
return third;
}
int GetSameDiceCount(int first, int second, int third)
{
if (first == second && first == third) {
return THREE;
}
if (first != second && first != third && second != third) {
return ONE;
}
return TWO;
}
int GetWinningPrize(int first, int second, int third)
{
int base_prize = 0;
int adder = 0;
int count = GetSameDiceCount(first, second, third);
if (count == ONE) {
adder = GetMaximumDice(first, second, third) * ONE_DICE_SAME_MULTIPLY;
return base_prize + adder;
}
if (count == TWO) {
base_prize = TWO_DICES_SAME_PRIZE;
adder = GetSameDice(first, second, third) * TWO_DICES_SAME_MULTIPLY;
return base_prize + adder;
}
base_prize = THREE_DICES_SAME_PRIZE;
adder = GetSameDice(first, second, third) * THREE_DICES_SAME_MULTIPLY;
return base_prize + adder;
}
void PrintWinningPrize(int first, int second, int third)
{
int prize = GetWinningPrize(first, second, third);
printf("%d\n", prize);
}
int main(void)
{
int first, second, third;
scanf("%d %d %d", &first, &second, &third);
PrintWinningPrize(first, second, third);
}