분류 전체보기48 [BOJ/Python] 10773번 제로 https://www.acmicpc.net/problem/10773 stack=[] tmp = 0 k=int(input()) for i in range(0,k): tmp = int(input()) if tmp==0: stack.pop() else: stack.append(tmp) print(sum(stack)) 2022. 6. 30. [BOJ/Python] 11653번 소인수분해 https://www.acmicpc.net/problem/11653 11653번: 소인수분해 첫째 줄에 정수 N (1 ≤ N ≤ 10,000,000)이 주어진다. www.acmicpc.net n = int(input()) lst = [] for i in range(2,n+1): if (n % i == 0): lst.append(i) i = 2 print(lst) 그냥 약수 출력 프로그램이 되어버렸다. n = int(input()) lst = [] for i in range(2,n+1): if (n % i == 0): lst.append(i) n = (n // i) print(lst) 뭔가 비슷하게 나오긴 하는데 4가 나와서 제대로 소인수분해가 안 된 것 같음 나누어지면 리스트 append하고 i를 다시 .. 2022. 6. 30. [BOJ/Python] 1543번 문서 검색 https://www.acmicpc.net/problem/1543 1543번: 문서 검색 세준이는 영어로만 이루어진 어떤 문서를 검색하는 함수를 만들려고 한다. 이 함수는 어떤 단어가 총 몇 번 등장하는지 세려고 한다. 그러나, 세준이의 함수는 중복되어 세는 것은 빼고 세야 한 www.acmicpc.net word = input() find = input() cnt = 0 index = 0 for i in range(len(word)): if ( word[index : index+len(find)] == find ): cnt += 1 index += len(find) else : index+=1 print(cnt) 처음에 index를 그냥 i라고 설정했더니 for문 i랑 겹쳐서 희한하게 출력이 됐었다. .. 2022. 6. 30. [BOJ/Python] 5568번 카드 놓기 https://www.acmicpc.net/problem/5568 5568번: 카드 놓기 예제 1의 경우 상근이는 11, 12, 21, 112, 121, 122, 212를 만들 수 있다. www.acmicpc.net from itertools import permutations n = int(input()) k = int(input()) lst = [] result = set() for i in range(n): a = input() lst.append(a) for per in permutations(lst,k): result.add("".join(per)) print(len(result)) 2022. 6. 30. 이전 1 ··· 8 9 10 11 12 다음