본문 바로가기

카테고리 없음

(C++) - 백준(BOJ) 6763번 : Speed fines are not fine!

반응형

https://www.acmicpc.net/problem/6763

 

6763번: Speed fines are not fine!

Many communities now have “radar” signs that tell drivers what their speed is, in the hope that they will slow down. You will output a message for a “radar” sign. The message will display information to a driver based on his/her speed according to

www.acmicpc.net

간단한 구현문제였습니다.

 

 

 

📕 풀이방법

 차이를 구하고 구간마다 요금을 찾아냅니다.


 

 

📕 Code

#include <bits/stdc++.h>
using namespace std;
int a, b, diff;
int main(){
    cin >> a >> b;
    diff = a - b;
    if(diff >= 0)
        cout << "Congratulations, you are within the speed limit!";
    else{
        cout << "You are speeding and your fine is $";
        if(1 <= -diff && -diff <= 20) cout << 100;
        else if(21 <= -diff && -diff <= 30) cout << 270;
        else if(-diff >= 31) cout << 500;
        cout << ".";
    }
}