본문 바로가기
[PS] 문제풀이/백준

[ 백준 1712 ] 손익분기점 (C++)

by 안산학생 2020. 2. 27.

[문제보기]

 

[해결과정]

 

 1. input : long long int 타입으로 a, b, c 입력

 2. a + bx > cx 를 찾기

   -> 예외 처리 b>=c 인 경우...

 

[소스코드]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/*
    BOJ 1712 - 손익분기점
    Created by haejun on 2020/02/27
*/
#include<iostream>
#include<vector>
#include<queue>
#include<memory.h>
#include<math.h>
#include<algorithm>
using namespace std;
#define ll long long int
 
ll a, b, c;
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    cin >> a >> b >> c;
    if (b >= c) {
        cout << -1 << "\n";
        return 0;
    }
 
    ll ans = a / (c - b) + 1;
    cout << ans << "\n";
 
    return 0;
}
 
 

[해결 과정 중 실수한 부분]

 1차 방정식을.. 생각치 않고 단순히 코딩으로만 풀려했던 실수..!

 

 브론즈 문제라고 무시하지 말기.!

 

 

[관련 문제 혹은 비슷한 문제]

 수학

 

댓글