6일차 설탕공장 알고리즘(최대한 적은 수의 봉지로 배달하기)
Console Programming/C# Console 2019. 9. 25. 14:13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Syntax15
{
class Program
{
static void Main(string[] args)
{
int quotient=0;
bool isRemain=false;
for (int i = input/5; i >-1; i--)
{
for (int j = input/3; j >-1; j--)
{
isRemain = (input == (5 * i + 3 * j));
//Console.WriteLine($"isRemain = {isRemain}, i = {i}, j={j} ");
if (isRemain)
{
quotient = i + j;
//Console.WriteLine($"quotient={quotient}");
break;
}
}
if(isRemain)
{ break;
}
}
if (isRemain)
{
Console.WriteLine(quotient);
}
else
{
Console.WriteLine(-1);
}
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
![](https://blog.kakaocdn.net/dn/SAqII/btqyAcflKdG/VmTWNbvznOXm6iP5LXUkn1/img.png)
'Console Programming > C# Console' 카테고리의 다른 글
백준 2557 Hello World (0) | 2019.09.25 |
---|---|
bool 논리 연산자 (0) | 2019.09.25 |
6일차 알람 45분 일찍 맞추기 (0) | 2019.09.25 |
6일차 두정수 A, B를 입력받아 크기를 비교하는 프로그램 (0) | 2019.09.25 |
6일차 문자열 표현식들 (0) | 2019.09.25 |