백준 16943 c++ [숫자재배치]


백준 16943 c++ [숫자재배치]

#include #include #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int a, b, c; c = -1; cin >> a >> b; string str = to_string(a); sort(str.begin(), str.end());//next_permutation을 사용하기 위해 오름차순 정렬 do { int num = stoi(str); if (str[0] == '0')continue;//문자열의 첫번째 문자가 0이면 정수로변환했을때 자리수가 변경됨으로 순열X if (num < b && c < num)//b보다 작으면서 현..


원문링크 : 백준 16943 c++ [숫자재배치]