Editorial for [sw] 톱니바퀴

이 해설은 꼭 필요할 때만 사용하고, 코드를 복사-붙여넣기 하지 마세요. 문제 출제자와 해설 작성자를 존중해 주세요.
문제를 직접 풀기 전에 공식 해답을 제출하는 것은 제재 대상입니다.

출제자: admin

태그: 구현
해설

처음과 마지막 톱니바퀴만 비교하면 된다.

정답 코드
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <memory.h>
#include <math.h>
#include <map>
#include <set>
#include <limits.h>
#include <tuple>
using namespace std;

#define X first
#define Y second
#define ll long long
#define ld long double
#define INF INT32_MAX
#define sz(x) (int)(x).size()
const int MAX = 1000005;

int n;
int arr[105];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    for (int i = 0; i < n; i++) cin >> arr[i];

    int a = arr[0];
    int b = arr[n - 1];

    if (a >= b) cout << 1 << '\n';
    else {
        int ans = b / a;
        if (b % a != 0) ans++;
        cout << ans << '\n';
    }

    return 0;
}

댓글

현재 작성된 댓글이 없습니다.