๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€(BOJ)

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 1076 - ์ €ํ•ญ

by YWTechIT 2021. 6. 7.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 1076 - ์ €ํ•ญ

๋ฐฑ์ค€ 1076 - ์ €ํ•ญ


โšก๏ธ ๋‚˜์˜ ํ’€์ด

์ €ํ•ญ ๋ฌธ์ œ์˜ ํ•ต์‹ฌ์€ ์ฒซ ๋ฒˆ์งธ์™€ ๋‘ ๋ฒˆ์งธ ์ƒ‰์€ ๋”ํ•ด์ฃผ๊ณ  ๋งˆ์ง€๋ง‰ ์ƒ‰์€ ๊ณฑํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•์ธ๋ฐ, ๋ฌด์ž‘์ • strํ˜•์œผ๋กœ ๋ฐ”๊ฟ” ๋”ํ•ด์ฃผ๋Š” ๋ฐฉ๋ฒ•๋งŒ ์ƒ๊ฐํ–ˆ๋‹ค. ๊ทธ๊ฒƒ๋ณด๋‹ค ์ฒซ ๋ฒˆ์งธ ์ƒ‰์— 10์„ ๊ณฑํ•˜๊ณ  ๋‘ ๋ฒˆ์งธ ์ƒ‰์€ ๊ทธ๋Œ€๋กœ ๋”ํ•ด์ฃผ๋Š” ๊ฒŒ ๊ฐ€๋…์„ฑ์ด ๋” ์ข‹์•˜๋‹ค.

 

๊ทธ๋ฆฌ๊ณ  10์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ์„ ์ด์šฉํ•˜๋ฉด ์‰ฝ๊ฒŒ ๊ณ„์‚ฐ ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ ๊ทœ์น™์„ ํŒŒ์•…ํ•˜์ง€ ๋ชปํ•ด resisters[color][2]์— ๋ฌด์ž‘์ • 10์˜ ๊ฑฐ๋“ญ์ œ๊ณฑ์„ ๋„ฃ์—ˆ๋‹ค. ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ์ฝ”๋“œ๋ฅผ ๋ณด๋‹ˆ๊นŒ ๊ทœ์น™์˜ ์ค‘์š”์„ฑ์„ ํ•œ๋ฒˆ ๋” ๋Š๊ผˆ๋‹ค.

 

# ๋‚˜์˜ ์ฝ”๋“œ
colors = [input() for _ in range(3)]
resisters = {'black': [0, 1], 'brown': [1, 10], 'red': [2, 100], 'orange': [3, 1000],
             'yellow': [4, 10000], 'green': [5, 100000], 'blue': [6, 1000000], 'violet': [7, 10000000],
             'grey': [8, 100000000], 'white': [9, 1000000000]}

value = str(resisters[colors[0]][0]) + str(resisters[colors[1]][0])
result = int(value) * resisters[colors[2]][1]

print(result)

 

# ๋‹ค๋ฅธ ์‚ฌ๋žŒ์˜ ์ฝ”๋“œ
a = input()
b = input()
c = input()
resisters = {'black': 0, 'brown': 1, 'red': 2, 'orange': 3,
             'yellow': 4, 'green': 5, 'blue': 6, 'violet': 7,
             'grey': 8, 'white': 9}

print((resisters[a] * 10 + resisters[b]) * (10 ** resisters[c]))
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€