티스토리 뷰
문제링크 : https://www.acmicpc.net/problem/24313
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a1, a0, c, n0;
int arr[101];
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> a1 >> a0 >> c >> n0;
int tmp1 = a1*n0+a0;
int tmp2 = c * n0;
if (a1 > c) cout << 0;
else cout << (tmp1<=tmp2 ? 1 : 0);
return 0;
}
문제에 주어진 조건을 그대로 따라하면 된다.
다만 주의할점으로 a1이 c보다 큰지 체크해야한다.
만약 a1 > c라면 어떤 n에서도 c * n이 a1 * n + a0보다 클 수 없기 때문에 0을 출력해야 한다.
'백준 > 실버' 카테고리의 다른 글
[백준 13909번] 창문 닫기 (C++) (0) | 2025.03.30 |
---|---|
[백준 13241]번 최소공배수 (C++) (0) | 2025.03.30 |
[백준 9613번] GCD 합 (C++) (0) | 2025.03.27 |
[백준 2485번] 가로수 (C++) (0) | 2025.03.27 |
[백준 1735번] 분수 합 (C++) (0) | 2025.03.27 |