무지성 공부방/알고리즘 해결
[BOJ_Python] 2869번, 1620번
hyerang0125
2020. 7. 22. 23:09
#2896
- 풀이
A, B, V = map(int,input().split())
print((V-B-1)//(A-B)+1)
cf> '(V-A)/(A-B)' 사용 안한 이유 : 만약 4.1일이 된다면 5일이지만, 출력은 4로 되기 때문에 식이 성립되지 않는다.
- 도출식
달팽이가 k일째 정상이라면, 높이 <= A*K - B*(K-1) (A-B)*K >= V - k K >= (V-B-1)/(A-B) |
#1620
- 풀이
import sys
N, M = map(int,input().split())
number_pokemon = 1
pokemon_dict1 = {}
pokemon_dict2 = {}
for _ in range(N):
name = str(sys.stdin.readline()).strip()
pokemon_dict1[numver_pokemon] = name
pokemeon_diect2[name] = number_pokemon
number_pokemon += 1
answer = []
for _ in range(M):
pokemon = str(sys.stdin.readline()).strip()
try:
print(pokemon_dict1[int(pokemon)]
except:
print(pokemon_dict2[pokemon])
cf> 입력이 숫자면 문자출력, 입력이 문자면 숫자출력하기.