Advertisement
Zuneve

wadaaaaaaaaaaaaa

Jan 15th, 2023
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<cmath>
  4. #include<algorithm>
  5. using namespace std;
  6. int main() {
  7. vector<int> a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  8. while (next_permutation(a.begin(), a.end())) {
  9. int ans = 0;
  10. for(int i = 8; i >= 0; --i)
  11. {
  12. ans = ans * 10 + a[i];
  13. }
  14. int r=0, k=0, l=10, n=ans;
  15. while (k<9) {
  16. int m = 0, s = 0, t;
  17. while (s<9) {
  18. int z=int(n/pow(10,s))%10;
  19. if (z>m and z<l) {
  20. m=z;
  21. } s+=1;
  22. } if (m>0) {
  23. r=10*r+t;
  24. k++;
  25. l=m;
  26. }
  27. } if (r==473160285) cout << ans;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement