题目链接

来个水题。。难得的1Y。

 #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define LL __int64
int flag[],que[];
LL fact[];
int n;
LL m;
void dfs(LL x,int step)
{
LL temp = ;
int i;
for(i = ;i <= n;i ++)
{
if(!flag[i])
{
if(temp + fact[n-step] >= x)
{
flag[i] = ;
que[step] = i;
dfs(x-temp,step+);
return ;
}
temp += fact[n-step];
}
}
}
int main()
{
int i;
fact[] = ;
for(i = ;i <= ;i ++)
fact[i] = fact[i-]*i;
scanf("%d%I64d",&n,&m);
dfs(m,);
for(i = ;i <= n;i ++)
{
if(i == )
printf("%d",que[i]);
else
printf(" %d",que[i]);
}
printf("\n");
return ;
}

Vijos 1092 全排列的更多相关文章

  1. Vijos——T 1092 全排列

    https://vijos.org/p/1092 描述 输入两个自然数m,n 1<=n<=20,1<=m<=n!输出n个数的第m种全排列. 如 :输入 3 1输出 1 2 3 ...

  2. vijosP1092 全排列

    vijosP1092 全排列 链接:https://vijos.org/p/1092 [思路] 数学+搜索. 根据序号依次确定每一个数. 首先我们可以把未选的数看作一个可选择集合,其次把寻找过程看作一 ...

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

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

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

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

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

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

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

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

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

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

  8. [LeetCode] Permutations 全排列

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

  9. 【BZOJ 1061】【Vijos 1825】【NOI 2008】志愿者招募

    http://www.lydsy.com/JudgeOnline/problem.php?id=1061 https://vijos.org/p/1825 直接上姜爷论文... #include< ...

随机推荐

  1. .net学习之CTS、CLS和CLR

    CLR:公共语言运行时,就是所有.net语言写的程序的公共运行时环境,比如C#.VB.Net等语言写的程序需要运行在CLR上,然后CLR解析执行操作系统的相关指令,CLR是.net程序运行在操作系统的 ...

  2. Windows 10 周年更新正式版下载 + win10 快捷键

    Windows 10 周年更新正式版  360云资源总汇(施工中): https://yunpan.cn/c6Svi7Az52XBs (提取码:e5dd)今后提到周年更新版.1607版或RS1版,都是 ...

  3. JS手机浏览器判断(转)

    整理查询一下,js判断手机浏览器的方法 <script type="text/javascript"> /* * 智能机浏览器版本信息:包括微信内置 * */ var ...

  4. SQL高级查询技巧(两次JOIN同一个表,自包含JOIN,不等JOIN)

    掌握了这些,就比较高级啦 Using the Same Table Twice 如下面查询中的branch字段 SELECT a.account_id, e.emp_id, b_a.name open ...

  5. elementar OS体验

    关于其说明请参考https://linuxtoy.org/archives/elementary-os-luna.html

  6. gitlab安装部署

    参考文章: https://gitlab.com/gitlab-org/gitlab-recipes/tree/master/install/centos http://www.xsjxmx.com/ ...

  7. php mysql PDO基本操作

    <?php $dbh = new PDO('mysql:host=localhost;dbname=localhost', 'root', ''); $dbh->setAttribute( ...

  8. Entity Framework Code First for SQL Compact

    这篇博客将介绍EF Code First中如何使用SQL Compact.SQL Compact是微软推出的免费的关系型数据库,目前最新版本是SQL Compact 4.0.微软的开发工具VS 201 ...

  9. set[c++]

    #include <iostream> using namespace std; #include <set> int main(int argc, const char * ...

  10. POJ 2114 Boatherds 树分治

    Boatherds     Description Boatherds Inc. is a sailing company operating in the country of Trabantust ...