코딩테스트 문제 풀이/[백준] 기본 수학1(9)
-
[C#] 백준 1011번 Fly me to the Alpha Centauri
정답 코드 : using System; namespace _9 { 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(' '); long x = Convert.ToInt32(inputData[0].ToString()); long y = Convert.ToInt32(inputData[1].ToString()); long an = 2; long k = 2; long d = y - x; long count = 1; lon..
2021.12.22 -
[C#] 백준 10757번 큰 수 A+B
정답 코드 : using System; using System.Numerics; namespace _8 { class Program { static void Main(string[] args) { string input = Console.ReadLine(); string[] inputData = input.Split(' '); BigInteger idx1 = BigInteger.Parse(inputData[0]); BigInteger idx2 = BigInteger.Parse(inputData[1]); Console.WriteLine(idx1 + idx2); } } } 10의 1만승은 데이터타입으로 표현이 불가능하다. C#에는 이런 큰값 계산을 위한 메소드가 있다. BigInteger를 사용하면 그냥 계..
2021.12.21 -
[C#] 백준 2839번 설탕 배달
정답 코드 : using System; namespace _7 { class Program { static void Main(string[] args) { int input = Convert.ToInt32(Console.ReadLine()); int inputSave = input; int divisionFive = input / 5; int min = 10000; if (input % 3 == 0 && min > input / 3) min = input / 3; for (int i = 1; i < divisionFive + 1; i++) { input = inputSave; input -= 5 * i; if(input % 3 == 0) { int divisionThree = input / 3; if(m..
2021.12.21 -
[C#] 백준 2775번 부녀회장이 될테야
정답 코드 : using System; namespace _6 { class Program { static void Main(string[] args) { int T = Convert.ToInt32(Console.ReadLine()); for (int K = 0; K < T; K++) { int k = Convert.ToInt32(Console.ReadLine()); //층 int n = Convert.ToInt32(Console.ReadLine()); //호 int person = 0; int[,] room = new int[n, k + 1]; //4층에 3호를 구하고 싶으면 0층 1호를 (1,1)으로 기준점을 잡고 (3,4)를 구한다. int[] Floor0 = new int[n]; for (int ..
2021.12.21 -
[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