Algorithm, Data structure/Solved Algorithmic Problem

BAEKJOON 2869 - PUŽ

JaykayChoi 2016. 12. 26. 23:48

문제: https://www.acmicpc.net/problem/2869



문제

There is a snail on the ground. It wants to climb to the top of a wooden pole with the height of V meters, measuring from the ground level. In one day it can climb A meters upwards, however during each night it sleeps, sliding B meters back down. Determine the number of days it needs to climb to the top. 

입력

The first and only line of input contains three integers separated by a single space: A, B, and V (1 ≤ B < A ≤ V ≤ 1 000 000 000), with meanings described above. 

출력

The first and only line of output must contain the number of days that the snail needs to reach the top. 

 

예제 입력 

2 1 5

예제 출력 

4

힌트


이분 탐색 문제를 골라서 풀고 있는데 이 문제는 간단하게 산수로 풀 수 있는 문제네요.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma warning (disable:4996)
#include <cstring>
#include <climits>
#include <algorithm>
 
using namespace std;
typedef long long ll;
 
int main()
{
    ll a, b, v;
    scanf("%d %d %d"&a, &b, &v);
    ll ret = + (v - a) / (a - b);
    if ((v - a) % (a - b) != 0)
        ret++;
    printf("%d\n", ret);
    
    return 0;
}
cs


'Algorithm, Data structure > Solved Algorithmic Problem' 카테고리의 다른 글

BAEKJOON 2512 - 예산  (0) 2016.12.30
BAEKJOON 2805 - EKO  (0) 2016.12.28
BAEKJOON 10815 - 숫자 카드  (0) 2016.12.26
BAEKJOON 1920 - 수 찾기  (0) 2016.12.25
BAEKJOON 2193 - 이친수  (0) 2016.12.25