题目链接

来个水题。。难得的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. JavaWeb学习之JSTL自定义标签库的使用、JSTL自定义函数库(7)

    一.自定义标签,步骤 * 确定需求 * <my:date /> 输出当前系统的时间 yyyy-MM-dd hh:mm:ss:SSS * 编写Java类 新建包名:com.yxl.tag,新 ...

  2. 【翻译二十三】java-并发程序之随机数和参考资料与问题(本系列完)

    Concurrent Random Numbers In JDK 7, java.util.concurrent includes a convenience class, ThreadLocalRa ...

  3. poj 2236:Wireless Network(并查集,提高题)

    Wireless Network Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 16065   Accepted: 677 ...

  4. 攻城狮在路上(叁)Linux(十七)--- linux磁盘与文件管理概述

    一.复习知识点: 1.扇区是最小的物理存储单位,大小为512bytes. 2.扇区组成一个圆,成为柱面,柱面是分区的最小单位. 3.第一个扇区很重要,因为包含了MBR(446字节)和分区表(64字节) ...

  5. oracle相关环境变量配置

    ORACLE_HOME:D:\Program File\oracle\product\10.2.0\db_1 ORACLE_SID:orcl Path中增加:D:\ProgramFile\oracle ...

  6. Linux 下编译自己的 OpenJDK7 包括JVM和JDK API

    1.首先去 这里 http://download.java.net/openjdk/jdk7/ 下载OpenJDK7的源码zip包 2. 简要介绍下OpenJDK7中的目录 hotspot: 放有Op ...

  7. 分佈式事務故障處理暨ORA-24756: transaction does not exist處理

    ORA-24756处理 看到警告日誌一直報ORA-24756錯誤 Errors in file /oracle/admin/NHMIX01/bdump/nhmix01_reco_4959.trc: O ...

  8. Storyboards

    这里是吐槽时间,换掉了mac默认的输入法,出发点只有一个,就是切换中英文输入的时候相当不爽.也许是习惯了其他各大输入法的一键切换,而又没有找到自带输入法可设置的地方. Segue 以前我们使用navi ...

  9. Jquery获取iframe子/父窗口中的标签

    获取子窗口中的标签: $("#id",document.frames('iframename').document); 获取父窗口中的标签: $('#id', parent.doc ...

  10. 实现一种快速查找Richedit中可见区域内OLE对象的方法

    Richedit是一个OLE容器,使用Richedit来显示IM聊天内容时,通常使用OLE对象来实现在Richedit中播放表情动画. 触发表情的绘制有两种途径: 1.来自Richedit的刷新消息. ...