Seize your moment! ๐Ÿ‘พ

์•ˆ๋…•ํ•˜์„ธ์š”. Eric์ž…๋‹ˆ๋‹ค. ์ œ ๋ธ”๋กœ๊ทธ์— ๋ฐฉ๋ฌธํ•ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ’ป ๊ฐœ๋ฐœ๊ณต๋ถ€/Algorithm

[Eric's ๋ฐฑ์ค€] 1712๋ฒˆ - ์†์ต๋ถ„๊ธฐ์  - Java

Eric_ko 2023. 1. 17. 22:15

 

๋ฐฑ์ค€ 1712๋ฒˆ ๋ฌธ์ œ ์†์ต๋ถ„๊ธฐ์  ์ž…๋‹ˆ๋‹ค.

์ œ๊ฐ€ ํ•˜๋‹จ๊ณผ ๊ฐ™์ด ํ‘ผ ์ด์œ ๋Š”

๋งŒ์•ฝ b๊ฐ’์ด c๋ณด๋‹ค ํฌ๊ฑฐ๋‚˜ ๊ฐ™์œผ๋ฉด

์•„๋ฌด๋ฆฌ ๋ฌผ๊ฑด์„ ํŒ”์•„๋„ ์ด๋“์ด ๋‚˜์ง€ ์•Š๊ธฐ์—

๋ฐ”๋กœ -1 ์„ ๋ฆฌํ„ดํ•˜์˜€๊ณ ,

 

๋‚˜๋จธ์ง€ ๊ฐ’๋“ค์€ 

b -c ๋กœ price ๊ฐ’์„ ๊ตฌํ•ด์„œ

a๋ฅผ price ๋กœ ๋‚˜๋ˆ„๊ณ  +1 ์„ ์ง„ํ–‰ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

๊ทธ ์ด์œ ๋Š” a์—์„œ price ๋กœ ๋‚˜๋ˆ„์—ˆ์„๋•Œ์˜ ๋ชซ์ด

ํŒ๋งคํ–ˆ์„๋•Œ์˜ ์†์ต๋ถ„๊ธฐ์ ์˜ ๋”ฑ ์ด์ „ ๊ฐ’์ด์—ฌ์„œ

์ด ๋ชซ์— 1์„ ๋”ํ•ด์„œ ๊ตฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.

 

import java.util.Scanner;

public class N1712 {
    public static void main(String[] args) {
        N1712 T = new N1712();
        Scanner kb = new Scanner(System.in);
        int a = kb.nextInt();
        int b = kb.nextInt();
        int c = kb.nextInt();
        System.out.println(T.solution(a, b, c));
    }

    public int solution(int a, int b, int c){
        int answer = -1;
        if(b>=c){
            return answer;
        }else {
            int price = c - b;
            answer = a / price +1;
        }
        return answer;
    }
}

Solved.ac ํ”„๋กœํ•„