-
백준 16943 python백준/브루트포스 알고리즘 2023. 4. 10. 17:59
문제
https://www.acmicpc.net/problem/16943
풀이
- 파이썬 내장 순열 알고리즘을 이용해 튜플을 생성한다.
- 크기 순서대로 정렬하여 조건에 맞는 정답을 찾는다.
from itertools import permutations A,B=map(int, input().split()) A=list(map(int, str(A))) o=-1 for num in sorted(permutations(A,len(A))): if num[0]==0:continue x=int(''.join(map(str,num))) if x<B:o=x else:break print(o)
'백준 > 브루트포스 알고리즘' 카테고리의 다른 글
백준 16937 nodejs (0) 2023.02.23 백준 14502 nodejs (1) 2023.01.25 백준 12919 nodejs (0) 2023.01.19 백준 15686 nodejs (0) 2023.01.17 백준 1107 nodejs (0) 2022.12.09