본문 바로가기

Coding/백준 온라인 저지 (Baekjoon Online Judge)

백준 온라인 저지(Baekjoon Online Judge) - 1076 : 저항

https://www.acmicpc.net/problem/1076

 

1076번: 저항

첫째 줄에 첫 번째 색, 둘째 줄에 두 번째 색, 셋째 줄에 세 번째 색이 주어진다. 위의 표에 있는 색만 입력으로 주어진다.

www.acmicpc.net

 

#include <iostream>
#include <string>
using namespace std;

long long value(string str) {
	if (str == "black")
		return 0;
	else if (str == "brown")
		return 1;
	else if (str == "red")
		return 2;
	else if (str == "orange")
		return 3;
	else if (str == "yellow")
		return 4;
	else if (str == "green")
		return 5;
	else  if (str == "blue")
		return 6;
	else if (str == "violet")
		return 7;
	else if (str == "grey")
		return 8;
	else if (str == "white")
		return 9;
	else
		return -1;
}

int multiplication(string str) {
	if (str == "black")
		return 1;
	else if (str == "brown")
		return 10;
	else if (str == "red")
		return 100;
	else if (str == "orange")
		return 1000;
	else if (str == "yellow")
		return 10000;
	else if (str == "green")
		return 100000;
	else  if (str == "blue")
		return 1000000;
	else if (str == "violet")
		return 10000000;
	else if (str == "grey")
		return 100000000;
	else if (str == "white")
		return 1000000000;
	else
		return -1;
}

int main() {
	string str1, str2, str3;
	long long result = 0;
	cin >> str1 >> str2 >> str3;
	result = (value(str1) * 10 + value(str2)) * multiplication(str3);
	cout << result;
}