[백준] C# : 스타후르츠(17496번)

ssu_hyun·2022년 8월 25일
0

Data Structure & Algorithm

목록 보기
60/67
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Baekjoon
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1. 각 변수 입력받기
            int[] input = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int n = input[0];  // 여름 일 수
            int t = input[1];  // 자라는데 걸리는 일 수
            int c = input[2];  // 심을 수 있는 칸 수
            int p = input[3];  // 개당 수익

            // 2. 수확을 할 수 있는 최대 횟수를 구하는 while문
            int count = 0;  // 수확할 수 있는 최대 횟수
            int i = 1;
            bool isBreak = false;
            while (!isBreak)
            {
                // 종료 조건 : 수확일 > 여름일
                if (1+i * t > n)
                {
                    isBreak = true;
                }
                else
                {
                    i++;
                    count++;
                }
            }

            // 3. 총 수익 = 수확을 할 수 있는 최대 횟수 * 칸 수 * 개당 가격
            Console.WriteLine(count * c * p);
        }
    }
}

0개의 댓글