Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- #include<cmath>
- #include<algorithm>
- using namespace std;
- int main() {
- vector<int> a = {1, 2, 3, 4, 5, 6, 7, 8, 9};
- while (next_permutation(a.begin(), a.end())) {
- int ans = 0;
- for(int i = 8; i >= 0; --i)
- {
- ans = ans * 10 + a[i];
- }
- int r=0, k=0, l=10, n=ans;
- while (k<9) {
- int m = 0, s = 0, t;
- while (s<9) {
- int z=int(n/pow(10,s))%10;
- if (z>m and z<l) {
- m=z;
- } s+=1;
- } if (m>0) {
- r=10*r+t;
- k++;
- l=m;
- }
- } if (r==473160285) cout << ans;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement