반응형
SMALL
https://www.acmicpc.net/problem/10162
10162번: 전자레인지
3개의 시간조절용 버튼 A B C가 달린 전자레인지가 있다. 각 버튼마다 일정한 시간이 지정되어 있어 해당 버튼을 한번 누를 때마다 그 시간이 동작시간에 더해진다. 버튼 A, B, C에 지정된 시간은
www.acmicpc.net
문제

문제풀이
using System;
using System.IO;
namespace BOJ_10162
{
internal class Program
{
static int cntA;
static int cntB;
static int cntC;
static void Main(string[] args)
{
StreamReader sr = new StreamReader(new BufferedStream(Console.OpenStandardInput()));
StreamWriter sw = new StreamWriter(new BufferedStream(Console.OpenStandardOutput()));
int A = 300;
int B = 60;
int C = 10;
int T = int.Parse(sr.ReadLine()); //300;
for (int i = 0; i < 10000; i++)
{
if (T >= A)
{
T -= A;
cntA++;
if (T == 0)
{
break;
}
}
else if (T < A)
{
if (T >= B)
{
T -= B;
cntB++;
if (T == 0)
{
break;
}
}
else if (T < B)
{
T -= C;
cntC++;
if (T != 0 && T < C)
{
Console.WriteLine(-1);
break;
}
else if (T == 0) break;
}
}
}
if (T == 0)
sw.WriteLine("{0} {1} {2}", cntA, cntB, cntC);
sr.Close();
sw.Close();
}
}
}
반응형
LIST
'Algorithm > BOJ' 카테고리의 다른 글
| [BOJ] 1343번 폴리오미노 - C# 사용 - 미해결 (0) | 2023.02.04 |
|---|---|
| [BOJ] 2864 5와 6의 차이 c# 사용 풀이 (0) | 2023.02.01 |
| [BOJ] 1789번 수들의 합 C# 사용 풀이 (0) | 2023.01.31 |
| [BOJ] 체스판 다시 칠하기 (미해결) - 해결 (0) | 2023.01.31 |
| [BOJ] 중복 빼고 정렬하기 C# 사용 풀이 (2) | 2023.01.29 |