Vijos——T 1092 全排列
https://vijos.org/p/1092
描述
输入两个自然数m,n 1<=n<=20,1<=m<=n!
输出n个数的第m种全排列。
如 :
输入 3 1
输出 1 2 3
格式
输入格式
在一行中输入n m
输出格式
一个数列,既n个数的第m种排列
每两个数之间空1格
样例1
样例输入1
3 2
样例输出1
1 3 2
限制
各个测试点1s
来源
lk
#include <cstdio> #define LL long long
bool use[];
LL jc[];
int n,m; int AC()
{
scanf("%d%d",&n,&m); m--; jc[]=;
for(int i=; i<=n; ++i) jc[i]=(LL)jc[i-]*i;
for(int j,i=; i<=n; ++i)
{
LL tmp=(LL)m/jc[n-i];
m%=jc[n-i];
for(j=; j<=n; ++j)
if(!use[j])
{
if(!tmp) break;
tmp--;
}
use[j]=;
printf("%d ",j);
}
return ;
} int Aptal=AC();
int main(){;}
Vijos——T 1092 全排列的更多相关文章
- Vijos 1092 全排列
题目链接 来个水题..难得的1Y. #include <cstdio> #include <cstring> #include <iostream> using n ...
- vijosP1092 全排列
vijosP1092 全排列 链接:https://vijos.org/p/1092 [思路] 数学+搜索. 根据序号依次确定每一个数. 首先我们可以把未选的数看作一个可选择集合,其次把寻找过程看作一 ...
- PHP实现全排列(递归算法)
算法描述:如果用P表示n个元素的全排列,而Pi表示n个元素中不包含元素i的全排列,(i)Pi表示在排列Pi前面加上前缀i的排列,那么n个元素的全排列可递归定义为: ① 如果n=1,则排列P只有一 ...
- hdu5651 xiaoxin juju needs help (多重集的全排列+逆元)
xiaoxin juju needs help 题意:给你一个字符串,求打乱字符后,有多少种回文串. (题于文末) 知识点: n个元素,其中a1,a2,··· ...
- [LeetCode] Palindrome Permutation II 回文全排列之二
Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empt ...
- [LeetCode] Palindrome Permutation 回文全排列
Given a string, determine if a permutation of the string could form a palindrome. For example," ...
- [LeetCode] Permutations II 全排列之二
Given a collection of numbers that might contain duplicates, return all possible unique permutations ...
- [LeetCode] Permutations 全排列
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...
- 【BZOJ 1061】【Vijos 1825】【NOI 2008】志愿者招募
http://www.lydsy.com/JudgeOnline/problem.php?id=1061 https://vijos.org/p/1825 直接上姜爷论文... #include< ...
随机推荐
- C# Interactive Walkthrough
C# Interactive Walkthrough
- 操作系统-虚拟机-百科:VM
ylbtech-操作系统-虚拟机-百科:VM 虚拟机(Virtual Machine)指通过软件模拟的具有完整硬件系统功能的.运行在一个完全隔离环境中的完整计算机系统. 虚拟系统通过生成现有操作系统的 ...
- PCB Genesis增加点阵字 实现原理
我们采用Genesis增加点阵字时,用Genesis增加Canned Text即可,但奥宝中文不支持,且字符种类是有限的呀 不过没关系,没有自己造呀.在这里我分享一种增加点阵字的实现方法 一.通过代码 ...
- Django day17 博客项目(一)
一: 博客项目需求分析 首页(显示文章) 文章详情 点赞, 点踩 文章评论 字评论 评论的展示 登录功能(图片验证码) 注册功能(基于form验证,ajax) 个人站点(不同人不同样式,文章过滤) 后 ...
- springboot创建项目
Springboot作为轻量级快速开发受到无数java人的青睐,Spring Boot是为了简化Spring应用的创建.运行.调试.部署等而出现的,使用它可以做到专注于Spring应用的开发,而无需过 ...
- jdbc数据库中的增删改
HttpSession session=request.getSession(); session.setAttribute("currentUser",u.username);/ ...
- python请求服务器图片并下载到本地磁盘
>>> import os >>> os.getcwd() 'C:\\Python33' >>> os.chdir('E:\\python\\mm ...
- Windows7下caffe-ssd-microsoft下编译
整个编译可谓漫长 编译了两天 网上教程也很多 但是也很杂 遇到各种错误 总归是编完了 1.下载Windows版本的Caffe-SSD源码 下载链接:https://github.com/conner9 ...
- Spring JPA 简单配置使用
JPA 常用配置: # JPA (JpaBaseConfiguration, HibernateJpaAutoConfiguration) spring.data.jpa.repositories.b ...
- ThreadPoolExecutor理解
ThreadPoolExecutor组成 ThreadPoolExecutor的核心构造函数: public ThreadPoolExecutor(int corePoolSize, int maxi ...