• P1088 火星人


    这里用到了一个特别神奇的函数 STL里面algorithm头文件的一个函数 next_permutation() 返回给定范围中的元素组成的下一个按字典序的排列 即就是直接按照题意进下一个

    AC代码:

     1 #include<bits/stdc++.h>
     2 #define pi acos(-1)
     3 typedef long long ll;
     4 typedef unsigned long long ull;
     5 using namespace std;
     6 
     7 namespace io {
     8     const int SIZE = 1e7 + 10;
     9     char inbuff[SIZE];
    10     char *l, *r;
    11     inline void init() {
    12         l = inbuff;
    13         r = inbuff + fread(inbuff, 1, SIZE, stdin);
    14     }
    15     inline char gc() {
    16         if (l == r) init();
    17         return (l != r) ? *(l++) : EOF;
    18     }
    19     void read(int &x) {
    20         x = 0; char ch = gc();
    21         while(!isdigit(ch)) ch = gc();
    22         while(isdigit(ch)) x = x * 10 + ch - '0', ch = gc();
    23     }
    24 } using io::read;
    25 
    26 bool cmp(const int &a, const int &b){
    27     return a > b;
    28 }
    29 
    30 int main(){
    31     ios::sync_with_stdio(false);
    32     int n, m;
    33     cin>>n>>m;
    34     int a[10005];
    35     memset(a, 0, sizeof(a));
    36     for (int i = 1; i <= n; i++) cin>>a[i];
    37     while (m--) next_permutation(a + 1, a + n + 1);
    38     for (int i = 1; i < n; i++) cout<<a[i]<<' ';
    39     cout<<a[n]<<endl;
    40     return 0;
    41 }
  • 相关阅读:
    坑爹的A标签 href
    JS 遍历 json key ,获取设置可变的key
    js to json字符串
    js eval深入
    Js 省市联动
    JS with用法
    JS
    js 内置对象常用方法
    django-pure-pagination 分页插件
    OpenStack 网络服务 Neutron 私有网络构建(十九)
  • 原文地址:https://www.cnblogs.com/Misuchii/p/10976922.html
Copyright © 2020-2023  润新知