-
[백준] ⭐⭐ 7490 0만들기백준 Online Judge 2021. 8. 31. 16:33
7490번: 0 만들기
각 테스트 케이스에 대해 ASCII 순서에 따라 결과가 0이 되는 모든 수식을 출력한다. 각 테스트 케이스의 결과는 한 줄을 띄워 구분한다.
www.acmicpc.net
import copy def recursive(array, n): if len(array) == n: operators_list.append(copy.deepcopy(array)) return array.append(' ') recursive(array, n) array.pop() array.append('+') recursive(array, n) array.pop() array.append('-') recursive(array, n) array.pop() test_case = int(input()) for _ in range(test_case): operators_list = [] n = int(input()) recursive([], n - 1) integers = [i for i in range(1, n + 1)] for operators in operators_list: string = "" for i in range(n - 1): string += str(integers[i]) + operators[i] string += str(integers[-1]) if eval(string.replace(" ", "")) == 0: print(string) print()
GitHub - DAWUNHAN/Algorithms-and-DataStructure: Algorithms and DataStructure with Python
Algorithms and DataStructure with Python. Contribute to DAWUNHAN/Algorithms-and-DataStructure development by creating an account on GitHub.
github.com
[ 패스트캠퍼스 알고리즘 / 기술면접 완전 정복 올인원 패키지 Online ] 강의 내용을 정리한 자료입니다.
'백준 Online Judge' 카테고리의 다른 글
[백준] 11004 k번째 수 (0) 2021.08.31 [백준] 2751 수 정렬하기 2 (0) 2021.08.31 [백준] 1074 z (재귀 함수) (0) 2021.08.31 [백준] 1074 z (재귀 함수) (0) 2021.08.31 [백준] 2747 피보나치 수열 (0) 2021.08.31