#include<bits/stdc++.h>
using namespace std;
int a[+];
bool b[+];
int search(int k);
int print();
int n,num;
int main(){
cin>>n;
search();
cout<<num<<endl;
return ;
}
int search(int k){
for(int i=;i<=n;i++)
if(!b[i]){
a[k]=i;
b[i]=;
if(k==n) print();
else search(k+);
b[i]=;
} }
int print(){
num++;
for(int i=;i<=n;i++)
cout<<setw()<<a[i];
cout<<endl;
}

啦啦啦,又来了一遍全排列

luogu1706全排列的更多相关文章

  1. PHP实现全排列(递归算法)

    算法描述:如果用P表示n个元素的全排列,而Pi表示n个元素中不包含元素i的全排列,(i)Pi表示在排列Pi前面加上前缀i的排列,那么n个元素的全排列可递归定义为:    ① 如果n=1,则排列P只有一 ...

  2. hdu5651 xiaoxin juju needs help (多重集的全排列+逆元)

    xiaoxin juju needs help 题意:给你一个字符串,求打乱字符后,有多少种回文串.                      (题于文末) 知识点: n个元素,其中a1,a2,··· ...

  3. [LeetCode] Palindrome Permutation II 回文全排列之二

    Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...

  4. [LeetCode] Palindrome Permutation 回文全排列

    Given a string, determine if a permutation of the string could form a palindrome. For example," ...

  5. [LeetCode] Permutations II 全排列之二

    Given a collection of numbers that might contain duplicates, return all possible unique permutations ...

  6. [LeetCode] Permutations 全排列

    Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...

  7. 全排列算法的JS实现

    问题描述:给定一个字符串,输出该字符串所有排列的可能.如输入“abc”,输出“abc,acb,bca,bac,cab,cba”. 虽然原理很简单,然而我还是折腾了好一会才实现这个算法……这里主要记录的 ...

  8. java实现全排列

    前天上午的面试遇到了一个用java实现一串数字的全排列的题,想来想去用递归最方便,可是没有在规定的时间内完成555,今天上午有空便继续写,以下是完成后的代码: import java.util.Arr ...

  9. poj3187-Backward Digit Sums(枚举全排列)

    一,题意: 输入n,sum,求1~n的数,如何排列之后,相邻两列相加,直到得出最后的结果等于sum,输出1~n的排列(杨辉三角)  3 1 2 4 //1~n 全排列中的一个排列  4 3 6  7 ...

随机推荐

  1. docker17.03.2安装

    之前安装过docker 卸载 yum -y remove docker docker-common docker-selinux docker-engine docker-engine-selinux ...

  2. ERROR internal error: process exited while connecting to monitor

    centos7.4 创建kvm虚拟机时报错 问题: [root@oldboy ~]# virt-install --virt-type kvm --os-type=linux --os-variant ...

  3. centos卸载mysql

    1.查看系统安装mysql rpm -qa|grep -i mysql 2.卸载 rpm -ev --nodeps mysql-community-release-el7-5.noarch 3.查询剩 ...

  4. 错误模块“AspNetCoreModuleV2"解决

    如图 HTTP 错误 500.21 - Internal Server Error 处理程序"aspNetCore"在其模块列表中有一个错误模块"AspNetCoreMo ...

  5. ng/cli new skip install and do not create a folder

    ng new myApp --skip-install --directory ./

  6. web前端面试题 -- 2019最新,最全

    最近在找工作,面试了好多家公司,结果都不怎么理想.要么公司环境氛围不行,要么工资达不到理想的薪资.大部分公司对程序员的面试流程几乎都一样,来了先填一份登记表,写一套面试题,然后技术面,人事面.至于有的 ...

  7. 【搬运工】 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

    登陆mysql的时候,出现了这个问题: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' ( ...

  8. 数据类型 varchar 和 uniqueidentifier 在 add 运算符中不兼容

    select '<a href="/'+a.id +'" title="'+ a.title +'">'+a.Title+'</a>' ...

  9. 201806 数据处理 SQL、python、shell 哪家强...速度PK(上篇)

    最近在工作中,进行大量的数据处理,使用的是mysql5.7.22,发现当数据量级达到几十万之后,SQL执行速度明显变慢.尤其是当多个表join时,于是就尝试用python pandas进行数据处理,发 ...

  10. JedisPubSub

    MsgListener extends JedisPubSub notify-keyspace-events "KEA"