728x90
풀이
저작권이 있는 멜로디의 평균값 = 수록곡에 포함된 저작권이 있는 멜로디 개수 / 앨범에 수록된 곡의 개수
ex.
24(23.53 올림) = 894 / 38
I = X / A (여기서 I와 A는 직접 입력한다.)
구해야 하는 X = I*A를 하면 되는데,
핵심은 '올림'인데, 23.00000001 이 나와도 24가 된다.
A와 I는 한 줄에 입력/출력되어야 하기 때문에
A, I = map(int, input().split()) 로 적어준다.
다음 I의 경우 위에서 말한 것처럼 23.00000001 이어도 24로 올림이 되기 때문에
이 녀석이 실제로는 23.00000001 인지 23.111111 인지를 알기 위해 우선 -1을 해준다.
즉 I = int(I)-1이 되며, 이걸 print((A*I)+1) 하면 X값을 구할 수 있다.
적어도 몇 곡이 저작권이 있는 멜로디인지 구하기 위해 다시 1을 더해 정수화(?) 해주면 된다.
예를 들어보자면, A, I 를 10으로 입력해보자.
10(9.1이든 9.8이든 9.xx에서 올림해서 10이 됐다.) = X / 10
X = 100 처럼 보이겠지만, 올림이 된 거니까 1을 빼준다.
다시 X = 90.xxx 인데, 적어도 '몇 곡'이 되어야 하니 1을 더해서 91.xxx으로 만드는 거다.
왜 -1 하고 +1 인지 이해하기 어려웠는데 알고 보니 간단했다...
두 번째 코드처럼 해도 답은 같다.
코드
A, I = map(int, input().split())
I = int(I)-1
print((A*I)+1)
A, I = map(int, input().split())
I -= 1
print((A*I)+1)
728x90
'🥧 Python > ⚙️ 코딩테스트' 카테고리의 다른 글
[백준-Python] 2675번: 문자열 반복 (0) | 2023.02.15 |
---|---|
[백준-Python] 5355번: 화성 수학 (0) | 2023.02.15 |
[백준-Python] 2530번: 인공지능 시계 (0) | 2023.02.15 |
[백준-Python] 2525번: 오븐 시계 (0) | 2023.02.15 |
[백준-Python] 7287번: 등록 (0) | 2023.02.14 |