728x90

c# 33

[백준 15649번 c#] N과 M

- 브루트포스: 모든 경우의 수 - 백트래킹: 해당 노드의 유망성을 판단 - DFS(깊이우선탐색): 트리순회의 한 형태, 백트래킹에 사용하는 대표적인 탐색 알고리즘 백트래킹 = DFS가 아니라 백트래킹의 방법 중 하나가 DFS BFS(너비우선탐색) 등 다양한 방법으로 백트래킹을 구현가능 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static StringBuilder sb = new StringBuilde..

[백준 2004번 c#] 조합 0의 개수

- 조합: n!/(n-r)!r! 1. n!의 2,5 개수 , (n-r)! 의 2,5의 개수, (r!)의 2,5의 개수 구하기 2. n!의 2의 수에서 (n-r)! 와 r! 2의 수 더한거를 빼준다 3. n!의 5의 수에서 (n-r)! 와 r! 5의 수 더한거를 빼준다 4. 2,3번 중에 더 작은 값이 정답 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static void Main(string[] args)..

[백준 1676번 c#] 팩토리얼 0의 개수

-소인수분해 후, 5의 개수 구하기 using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static void Main(string[] args) { StreamWriter writer = new StreamWriter(Console.OpenStandardOutput()); StreamReader reader = new StreamReader(Console.OpenStandardInput()); StringBuil..

[9375번 c#]패션왕 신해빈

- c# 에서는 dictionary의 키에 대한 값에 접근할 때, 배열처럼 접근할 수 있다. - 만일, 같은 키값을 가진 값을 넣고 싶다면 dictionary로 넣을 수 있다. - 해당 문제는 조합 문제로, 옷의 종류에 각각 몇개씩 있는지 확인 후, (ㅁ+1)* (o+1) -1 로 구하면 된다. using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static void Main(string[] args) { Str..

[1934번 c#] 최소공배수

두 수를 곱한 값 -> 최대공약수 x 최소공배수 재귀를 이용하여 최대공약수와 최소공배수를 찾아준다. using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static void Main(string[] args) { StreamWriter writer = new StreamWriter(Console.OpenStandardOutput()); StreamReader reader = new StreamReader(Console.OpenStandardInput()); ..

[백준 c#] 24060번 알고리즘 수업 - 병합 정렬 1

using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { public static class Class1 { public static int count = 0; public static int ans = 0; static void merge_sort(int[] intArr, int p, int r, int num1, int[] temp) { //q는 중간값 if (p < r) { int q = (p + r) / 2; merge_sort(intArr, p, q, num1, temp); mer..

[백준 2798번 c#] 블랙잭

브루트포스 알고리즘 이 쓰인 문제이다. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Project2 { class Class1 { static void Main(string[] args) { //N,M 값 입력 string[] N_M = Console.ReadLine().Split(); int N = int.Parse(N_M[0]); int M = int.Parse(N_M[1]); //카드에 쓰여진 수 입력 string[] nums = Console.ReadLine().Split(); int[] numsInt = new int..

728x90