본문 바로가기

브루트포스5

백준 8892 팰린드롬 https://www.acmicpc.net/problem/8892 8892번: 팰린드롬 팰린드롬은 어느 방향으로 읽어도 항상 같은 방법으로 읽을 수 있는 단어이다. 예를 들어, civic, radar, rotor, madam은 팰린드롬이다. 상근이는 단어 k개 적혀있는 공책을 발견했다. 공책의 단어는 ICPC www.acmicpc.net 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 from itertools import permutations def check(s): if (s[0] + s[1]) == (s[0] + s[1])[::-1]: return s[0] + s[1] else: return False def solutio.. 2023. 11. 29.
백준 10448 유레카 이론 https://www.acmicpc.net/problem/10448 10448번: 유레카 이론 프로그램은 표준입력을 사용한다. 테스트케이스의 개수는 입력의 첫 번째 줄에 주어진다. 각 테스트케이스는 한 줄에 자연수 K (3 ≤ K ≤ 1,000)가 하나씩 포함되어있는 T개의 라인으로 구성되어 www.acmicpc.net 12345678910111213141516171819202122from itertools import combinations_with_replacement def solution(n): eureka = [1, 3, 6] start = 4 while n >= eureka[-1]: eureka.append(eureka[-1] + start) start += 1 pro = list(combin.. 2023. 11. 28.
백준 18141 Are They All Integers? https://www.acmicpc.net/problem/18141 18141번: Are They All Integers? Computing using integers is a dream for every programmer. That is, you do not have to deal with floating point numbers, estimated errors, and etc. We do not even need any floating point units in our computers for divisions! Your company claimed there is a www.acmicpc.net 1234567891011121314from itertools import permutationsdef .. 2023. 11. 28.
[백준] 2798 1 2 3 4 5 6 7 8 9 10 11 12 13 14 n,card =map(int, input().split()) a= list(map(int,input().split())) cnt=n ans=0 #a1,a2,a3=0 for i in range(0,n-2): for j in range(i+1,n-1): for k in range(j+1,n): if card 2021. 1. 8.
[백준] 2309 1 2 3 4 5 6 7 8 9 10 11 12 13 mylist=[] for _ in range(9): mylist.append(int (input())) mysum=sum(mylist) mylist.sort() for i in range(9): for j in range(i+1,9): if mysum-mylist[i]-mylist[j]==100: for k in range(9): if k==i or k==j:continue else: print(mylist[k]) exit() cs 다 더하고 하나씩 빼보면서 100인지 확인하는 방식으로 코드를 짰습니다. 이런 방식을 브루트포스(bruteforce)라고 합니다. 2021. 1. 7.