题目链接

来个水题。。难得的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. 【翻译二十】-java线程池

    Thread Pools Most of the executor implementations in java.util.concurrent use thread pools, which co ...

  2. sdut 1465 公共因子

    公共因子 Time Limit: 1000MS Memory limit: 65536K 题目描述 题目链接:http://acm.sdut.edu.cn/sdutoj/problem.php?act ...

  3. 使用RMAN DUPLICATE...FROM ACTIVE DATABASE创建物理standby database

    Applies to: Oracle Server - Enterprise Edition - Version 11.1.0.6 to 11.2.0.4 [Release 11.1 to 11.2] ...

  4. 湘潭邀请赛 Hamiltonian Path

    湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...

  5. 用脚本创建和恢复 DB2数据库

    CREATE DATABASE AUTOMATIC STORAGE YES ON 'C:\' DBPATH ON 'C:\' USING CODESET GBK TERRITORY CN COLLAT ...

  6. ASP.NET多线程下使用HttpContext.Current为null解决方案 2015-01-22 15:23 349人阅读 评论(0) 收藏

    问题一:多线程下获取文件绝对路径 当我们使用HttpContext.Current.Server.MapPath(strPath)获取绝对路径时HttpContext.Current为null,解决办 ...

  7. Implementing Navigation with UINavigationController

    Implementing Navigation with UINavigationController Problem You would like to allow your users to mo ...

  8. html5拖拽

    html5拖拽一 <!DOCTYPE html> <html> <head lang="en"> <meta charset=" ...

  9. IIS7报错

    错误内容:”未能加载文件或程序集“IWMS_Admin”或它的某一个依赖项.试图加载格式不正确的程“ 解决方法:进入IIS“应用程序池”,然后在右边列表中,选中当前网站所使用的程序池,打开右侧的“高级 ...

  10. 用C#基于WCF创建TCP的Service供Client端调用

    本文将详细讲解用C#基于WCF创建TCP的Service供Client端调用的详细过程 1):首先创建一个Windows Service的工程 2):生成的代码工程结构如下所示 3):我们将Servi ...