//https://www.acmicpc.net/problem/1076 #include <iostream> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
struct res{ | |
string color; | |
int value; | |
long long int digit; | |
}; | |
res table[10]; | |
void maketable(){ | |
table[0].color="black"; table[0].value=0; table[0].digit=1; | |
table[1].color="brown"; table[1].value=1; table[1].digit=10; | |
table[2].color="red"; table[2].value=2; table[2].digit=100; | |
table[3].color="orange"; table[3].value=3; table[3].digit=1000; | |
table[4].color="yellow"; table[4].value=4; table[4].digit=10000; | |
table[5].color="green"; table[5].value=5; table[5].digit=100000; | |
table[6].color="blue"; table[6].value=6; table[6].digit=1000000; | |
table[7].color="violet"; table[7].value=7; table[7].digit=10000000; | |
table[8].color="grey"; table[8].value=8; table[8].digit=100000000; | |
table[9].color="white"; table[9].value=9; table[9].digit=1000000000; | |
return; | |
} | |
int main(){ | |
maketable(); | |
string color; | |
long long int ans=0; | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans=table[i].value; | |
break; | |
} | |
} | |
ans*=10; | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans+=table[i].value; | |
break; | |
} | |
} | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans*=table[i].digit; | |
break; | |
} | |
} | |
cout << ans; | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180615_다음 큰 숫자 (0) | 2018.06.15 |
---|---|
180607_5597_과제안내신분? (0) | 2018.06.07 |
180604_10769_행복한지 슬픈지 (0) | 2018.06.04 |
180602_4690_완전 세제곱 (0) | 2018.06.02 |
180601_1934_최소공배수 (0) | 2018.06.01 |
//https://www.acmicpc.net/problem/1076 #include <iostream> | |
#include <vector> | |
#include <string> | |
using namespace std; | |
struct res{ | |
string color; | |
int value; | |
long long int digit; | |
}; | |
res table[10]; | |
void maketable(){ | |
table[0].color="black"; table[0].value=0; table[0].digit=1; | |
table[1].color="brown"; table[1].value=1; table[1].digit=10; | |
table[2].color="red"; table[2].value=2; table[2].digit=100; | |
table[3].color="orange"; table[3].value=3; table[3].digit=1000; | |
table[4].color="yellow"; table[4].value=4; table[4].digit=10000; | |
table[5].color="green"; table[5].value=5; table[5].digit=100000; | |
table[6].color="blue"; table[6].value=6; table[6].digit=1000000; | |
table[7].color="violet"; table[7].value=7; table[7].digit=10000000; | |
table[8].color="grey"; table[8].value=8; table[8].digit=100000000; | |
table[9].color="white"; table[9].value=9; table[9].digit=1000000000; | |
return; | |
} | |
int main(){ | |
maketable(); | |
string color; | |
long long int ans=0; | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans=table[i].value; | |
break; | |
} | |
} | |
ans*=10; | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans+=table[i].value; | |
break; | |
} | |
} | |
cin >> color; | |
for(int i=0; i<10; i++){ | |
if(table[i].color==color) { | |
ans*=table[i].digit; | |
break; | |
} | |
} | |
cout << ans; | |
return 0; | |
} |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
180615_다음 큰 숫자 (0) | 2018.06.15 |
---|---|
180607_5597_과제안내신분? (0) | 2018.06.07 |
180604_10769_행복한지 슬픈지 (0) | 2018.06.04 |
180602_4690_완전 세제곱 (0) | 2018.06.02 |
180601_1934_최소공배수 (0) | 2018.06.01 |