알고리즘 문제/Brute Force
-
topcoder SRM494 Div2 Level1 interesting party알고리즘 문제/Brute Force 2018. 2. 1. 12:00
topcoder SRM494 Div2 Level1 interesting party원 문제 주소 (로그인하고 하고 난뒤에 보임... 그냥 interesting party 로 검색하는게 더빠름)https://arena.topcoder.com/index.html#/u/practiceCode/14480/15196/11312/2/307028 공통된 단어를 찾는것이다.brute force 방식으로 전체탐색하면된다.n^2의 시간복잡도로 수행할 수 있다.n이 50까지였기에 망정이지만, 100만인경우 O(n)의 접근법으로 구현해야한다.그럴땐 맵 또는 딕셔너리 자료구조를 이용하면된다. C/C++ 소스보기https://github.com/ingyeoking13/algorithm/blob/master/topcoder/inte..
-
백준 1748 수 이어 쓰기 1알고리즘 문제/Brute Force 2018. 1. 26. 02:05
백준 1748 수 이어 쓰기 1 문제보기https://www.acmicpc.net/problem/1748 수를 n 까지 이어쓰는데, n까지 이어썼을 때 총 길이가 몇인지 세는 것이다.그래서 나는 len 함수를 만들어서 일일히 길이를 다 더해주기로 생각했다.함수는 log10 n 의 시간복잡도를 가지고, 총 n번 반복하니, n* logn 의 시간복잡도를 가지는 풀이이다. 좀더 멋진 풀이 방법이 있긴하다. 시간복잡도는 n이다.for 문을 딱 1번 1~n까지 순회하는데, i가 1~9까지는 1씩 길이가 더해지고, 10~99 까지는 2씩 길이를 더해준다.이렇게 하려면 int base = 10, cnt=1, ans=0;for (int i=1; i
-
863B : Kayaking알고리즘 문제/Brute Force 2017. 11. 5. 22:50
Difficulty : 4/10I could'nt solve this problem during the contest.but It is not difficult problem. This problem is brute force. first, you can try all combination of n-1 kayaks. but choosing 2 kayaks that soley drive is much easier. okay, then you could think about combination of n-1 tandem kayaks. here the greedy comes in. to minimize instability, you should choose two that have similar weight...