Last active
November 5, 2019 08:57
-
-
Save pinglunliao/6c37dc05753d07e4052f to your computer and use it in GitHub Desktop.
a524: 手機之謎. FYI: https://yunlinsong.blogspot.com/2016/02/a524.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
int n; | |
while( scanf("%d", &n) != EOF ) { | |
int *number = new int[n]; | |
for( int i = 0; i < n; i++ ) | |
number[i] = n - i; | |
do { | |
for( int i = 0; i < n; i++ ) | |
printf("%d", number[i]); | |
printf("\n"); | |
} while ( std::prev_permutation(number, number + n) ); | |
delete number; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment