https://www.acmicpc.net/problem/10162
10162번: 전자레인지
3개의 시간조절용 버튼 A B C가 달린 전자레인지가 있다. 각 버튼마다 일정한 시간이 지정되어 있어 해당 버튼을 한번 누를 때마다 그 시간이 동작시간에 더해진다. 버튼 A, B, C에 지정된 시간은
www.acmicpc.net
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace _230131_1
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
int a = 300;
int b = 60;
int c = 10;
int aCnt = 0;
int bCnt = 0;
int cCnt = 0;
int t = int.Parse(sr.ReadLine());
int tmp = t;
while (tmp >= a)
{
tmp -= a;
aCnt++;
}
while(tmp >= b)
{
tmp -= b;
bCnt++;
}
while(tmp >= 10)
{
tmp -= c;
cCnt++;
}
if (tmp < 10 && tmp > 0)
{
sw.WriteLine("-1");
}
else if (tmp == 0)
{
sw.WriteLine("{0} {1} {2}", aCnt, bCnt, cCnt);
}
sr.Close();
sw.Close();
}
}
}
'Algorithm > BOJ' 카테고리의 다른 글
C#) [BOJ] 2864 5와 6의 차이 (0) | 2023.01.31 |
---|---|
C#) [BOJ] 1789 수들의 합 ★ (0) | 2023.01.31 |
C#) [BOJ] 10815 숫자 카드★ (0) | 2023.01.28 |
C#) [BOJ] 4949 균형잡힌 세상 (0) | 2023.01.26 |
C#) [BOJ] 10828 스택 (0) | 2023.01.26 |