๐Ÿ‘ฉ‍๐Ÿ’ปProgramming/Coding Test

[C#] [BOJ#1712] ์†์ต๋ถ„๊ธฐ์ 

taesooya 2022. 8. 13.

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

 

1712๋ฒˆ: ์†์ต๋ถ„๊ธฐ์ 

์›”๋“œ์ „์ž๋Š” ๋…ธํŠธ๋ถ์„ ์ œ์กฐํ•˜๊ณ  ํŒ๋งคํ•˜๋Š” ํšŒ์‚ฌ์ด๋‹ค. ๋…ธํŠธ๋ถ ํŒ๋งค ๋Œ€์ˆ˜์— ์ƒ๊ด€์—†์ด ๋งค๋…„ ์ž„๋Œ€๋ฃŒ, ์žฌ์‚ฐ์„ธ, ๋ณดํ—˜๋ฃŒ, ๊ธ‰์—ฌ ๋“ฑ A๋งŒ์›์˜ ๊ณ ์ • ๋น„์šฉ์ด ๋“ค๋ฉฐ, ํ•œ ๋Œ€์˜ ๋…ธํŠธ๋ถ์„ ์ƒ์‚ฐํ•˜๋Š” ๋ฐ์—๋Š” ์žฌ๋ฃŒ๋น„์™€

www.acmicpc.net

 

My Solution

  • ์›๋ž˜๋Š” while ๊ตฌ๋ฌธ์œผ๋กœ x++ ์„ ํ–ˆ์œผ๋‚˜
  • (c-b)/a ๋ณด๋‹ค ๋”ฑ 1๋งŒํผ๋งŒ ๋งŽ์œผ๋ฉด ๋˜๋‹ˆ๊นŒ...

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] n = Console.ReadLine().Split();
            int a = int.Parse(n[0]);
            int b = int.Parse(n[1]);
            int c = int.Parse(n[2]);

            if (b >= c)
            {
                Console.WriteLine(-1);
            }
            else Console.WriteLine(a / (c - b) + 1);
        }
    **}
}

๋Œ“๊ธ€