코딩테스트 문제 풀이(88)
-
[C#] 백준 10250번 ACM 호텔
정답 코드 : using System; namespace _5 { class Program { static void Main(string[] args) { int T = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < T; i++) { string input = Console.ReadLine(); string[] inputData = input.Split(' '); double H = Convert.ToInt32(inputData[0]); double W = Convert.ToInt32(inputData[1]); double N = Convert.ToInt32(inputData[2]); double X = Math.Ceiling(N / H); //N이..
2021.12.21 -
[C#] 백준 2869번 달팽이는 올라가고 싶다
정답 코드 : using System; namespace _4 { internal class Program { static void Main(string[] args) { string input = Console.ReadLine(); string[] inputArray = input.Split(' '); double A = Convert.ToInt32(inputArray[0].ToString()); double B = Convert.ToInt32(inputArray[1].ToString()); double V = Convert.ToInt32(inputArray[2].ToString()); /* 5,1 6 일때 6-5인 1이라는 층이 있고 나는 한번에 5-1, 즉 4만큼 올라갈 수 있다. 반올림을 하지 않..
2021.12.21 -
[C#] 백준 1193번 분수찾기
정답 코드 : using System; namespace _3 { internal class Program { static void Main(string[] args) { int input = Convert.ToInt32(Console.ReadLine()); int x, y; int xValue = 1; int yValue = 1; int count = 1; bool isOdd = false; bool go = false; //대각선으로 내려가겠다 bool turn = false; //아래 혹은 옆으로 이동하는 작업을 했는가 판단해주는 값 int check; while (count < input)//(0,1), 2/1, isXzero == true { if(xValue == 1 || yValue ==1)..
2021.12.21 -
[C#] 백준 2292번 벌집
정답 코드 : using System; using System.Collections.Generic; namespace _2 { class Program { static void Main(string[] args) { int input = Convert.ToInt32(Console.ReadLine()); int n = 1; int k = n - 1; int output = 1; while (input > output) { output += 6 * (n-1); n++; } if (input == 1) Console.WriteLine(n); else Console.WriteLine(n-1); } } } 이 문제에는 규칙이 있다 바로 값들의 공차가 일정한 계차수열인 것이다. 따라서 계차수열을 구해주는 코드를 추..
2021.12.21 -
[C#] 백준 1712번 손익분기점
정답 코드 : using System; using static System.Console; namespace ConsoleApp3 { class Program { public static void Main(string[] args) { string abc = ReadLine(); string[] word = abc.Split(' '); //21억까지 int로 받을 수 있다 즉 21억까지 계속 계산하는 포문으로 만들게되면 안된다는 의미이다. int a = int.Parse(word[0]); int b = int.Parse(word[1]); int c = int.Parse(word[2]); if (b >= c) //b > c이면 아무리 계속 팔아도 순익분기점을 넘길 수 없음 { WriteLine(-1); r..
2021.12.21 -
[C#] 백준 1316번 그룹 단어 채커
using System; using System.Collections.Generic; namespace _10 { class Program { static void Main(string[] args) { int n = Convert.ToInt32(Console.ReadLine()); int count = 0; for (int k = 0; k = 2) { array.Add(input[0].ToString()); array.Add(input[1].ToS..
2021.12.19