알고리즘/BOJ
[C++] 백준 1076번 - 저항
Jay, Lee
2022. 2. 18. 20:12
map을 사용해서 간단히 풀 수 있는 문제
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
map<string, int> d = {
{"black", 0},
{"brown", 1},
{"red", 2},
{"orange", 3},
{"yellow", 4},
{"green", 5},
{"blue", 6},
{"violet", 7},
{"grey", 8},
{"white", 9},
};
string s1, s2, s3;
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> s1 >> s2 >> s3;
long long ans = d[s1] * 10 + d[s2];
for (int i = 0; i < d[s3]; i++) {
ans *= 10;
}
cout << ans << endl;
return 0;
}