T3000

Untitled

Jun 1st, 2022
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. void solve(ll pos, ll n)
  2. {
  3.     if (pos == n)
  4.     {
  5.         ll num = 0;
  6.         for (auto xl : aux)
  7.         {
  8.             num = num * 10 + z1.at(xl);
  9.         }
  10.         if (num > x && (sol == 0 || num < sol))
  11.         {
  12.             sol = num;
  13.         }
  14.     }
  15.     for (int i = 0; i < n; i++)
  16.     {
  17.         if (find(aux.begin(), aux.end(), i) == aux.end())
  18.         {
  19.             aux.push_back(i);
  20.             solve(pos + 1, n);
  21.             aux.pop_back();
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment