Skip to content

Commit

Permalink
[Bronze I] Title: 달팽이는 올라가고 싶다, Time: 32 ms, Memory: 33240 KB -Baekjo…
Browse files Browse the repository at this point in the history
…onHub
  • Loading branch information
ddubbu-dev committed Aug 9, 2024
1 parent b4c789d commit b43a1f6
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# [Bronze I] 달팽이는 올라가고 싶다 - 2869

[문제 링크](https://www.acmicpc.net/problem/2869)

### 성능 요약

메모리: 33240 KB, 시간: 32 ms

### 분류

수학

### 제출 일자

2024년 8월 9일 10:22:19

### 문제 설명

<p>땅 위에 달팽이가 있다. 이 달팽이는 높이가 V미터인 나무 막대를 올라갈 것이다.</p>

<p>달팽이는 낮에 A미터 올라갈 수 있다. 하지만, 밤에 잠을 자는 동안 B미터 미끄러진다. 또, 정상에 올라간 후에는 미끄러지지 않는다.</p>

<p>달팽이가 나무 막대를 모두 올라가려면, 며칠이 걸리는지 구하는 프로그램을 작성하시오.</p>

### 입력

<p>첫째 줄에 세 정수 A, B, V가 공백으로 구분되어서 주어진다. (1 ≤ B < A ≤ V ≤ 1,000,000,000)</p>

### 출력

<p>첫째 줄에 달팽이가 나무 막대를 모두 올라가는데 며칠이 걸리는지 출력한다.</p>

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

import math

A, B, V = map(int, input().split())

"""
방법1) 수식
좋은점) 반복문 대비, 연산이 한번만 필요하니깐 더 효율적
distance = A - B
distance * (days-1) + A
"""
distance_per_day = A - B

days = math.ceil((V - A + distance_per_day) / distance_per_day)

print(days)


"""
방법2) 반복문
궁금한점) 10^9 이상 반복문을 돌경우 VSC 에서도 렉걸림, 이유가 뭘까?
"""
# days = 0 #총 일 수
# position = 0 #달팽이의 현재 위치

# while True:

# print("position", position)

# # 낮
# days += 1
# position += A

# if position >= V:
# print(days)
# break

# # 밤
# position -= B

0 comments on commit b43a1f6

Please sign in to comment.