标签:print har namespace -- next break getc col printf
1 #include <bits/stdc++.h> 2 using namespace std; 3 #define _for(i,a,b) for(int i = (a);i < b;i ++) 4 const int maxn = 10009; 5 typedef long long ll; 6 int N,M; 7 int a[maxn]; 8 inline ll read() 9 { 10 ll ans = 0; 11 char ch = getchar(), last = ‘ ‘; 12 while(!isdigit(ch)) last = ch, ch = getchar(); 13 while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - ‘0‘, ch = getchar(); 14 if(last == ‘-‘) ans = -ans; 15 return ans; 16 } 17 inline void write(ll x) 18 { 19 if(x < 0) x = -x, putchar(‘-‘); 20 if(x >= 10) write(x / 10); 21 putchar(x % 10 + ‘0‘); 22 } 23 24 int main() 25 { 26 N = read(),M = read(); 27 _for(i,0,N) 28 a[i] = read(); 29 do 30 { 31 if(M==0) 32 break; 33 M --; 34 }while(next_permutation(a,a+N)); 35 _for(i,0,N) 36 { 37 write(a[i]); 38 if(i!=N-1) 39 printf(" "); 40 } 41 return 0; 42 }
标签:print har namespace -- next break getc col printf
原文地址:https://www.cnblogs.com/Asurudo/p/11259014.html