HDU - 1027 - Ignatius and the Princess II(STL)

【GB28181】wvp-GB28181-pro++ZLMediaKit编译安装国标流媒体服务器教程(Windows平台) 本文基于ZMLMediaKit+WVP-PRO在windows平台进行编译部署GB28181平台,网上教程也比较多,都大同小异,实际操作过程中容易出错的地方也比较多:redis安装无密码,mysql安装后密码的修改以及wvp数据可的创建,配置文件侧修改,尤其是和端口相关的项,再就是运行服务时各种错误需要注意,常见的错误已经做了汇总,遇到问题大家不要怕,找到报错的地方查看定位即可。 阅读详情

Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, "I have three question for you, if you can work them out, I will release the Princess, or you will be my dinner, too." Ignatius says confidently, "OK, at last, I will save the Princess." 

"Now I will show you the first problem." feng5166 says, "Given a sequence of number 1 to N, we define that 1,2,3...N-1,N is the smallest sequence among all the sequence which can be composed with number 1 to N(each number can be and should be use only once in this problem). So it's easy to see the second smallest sequence is 1,2,3...N,N-1. Now I will give you two numbers, N and M. You should tell me the Mth smallest sequence which is composed with number 1 to N. It's easy, isn't is? Hahahahaha......" 
Can you help Ignatius to solve this problem? 

 Input

The input contains several test cases. Each test case consists of two numbers, N and M(1<=N<=1000, 1<=M<=10000). You may assume that there is always a sequence satisfied the BEelzebub's demand. The input is terminated by the end of file.

Output

 For each test case, you only have to output the sequence satisfied the BEelzebub's demand. When output a sequence, you should print a space between two numbers, but do not output any spaces after the last number. 

Sample Input

 

6 4
11 8

Sample Output

 

1 2 3 5 6 4
1 2 3 4 5 6 7 9 8 11 10

   此题大意是给出1~n这几个数全排列中第m小的那个排列。求全排列的题可使用STL里的next_permutation不断得到下一个排列,重复m-1次即得到第m个排列。

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int math[1001];

int main() {
	int n,m;
	while(~scanf("%d%d",&n,&m)){
		for(int i=0;i<n;i++)
			math[i]=i+1;	//输入1~n	
		for(int i=1;i<m;i++)
			next_permutation(math,math+n);//STL
		for(int i=0;i<n;i++){
			printf("%d",math[i]);
			if(i==n-1)//注意题目要求的格式:最后一个数后不能输出空格
				printf("\n");
			else
				printf(" ");
		}
	}
	return 0;
}

 

[Dify实战] 做企业内部助手时,最容易被低估的不是提示词,而是权限、状态同步和反馈回写 这篇文章围绕“做企业内部助手时”这个具体问题展开,很多团队做企业内部助手时,最先优化的是提示词,但真正决定系统能不能上线长期跑下去的,往往是权限边界、状态同步和反馈回写闭环。正文会结合Dify拆解节点设计、配置建议和测试样例,补充关键步骤、检查点和常见坑,帮助读者判断第一版该怎么落地,并把经验复用到自己的真实业务场景中。 阅读详情

相关推荐

希捷硬盘卡死修复实战:U盘启动盘制作与低格清零全流程

机械硬盘使用多年后常出现卡顿、假死、坏道等问题,很多用户在网上搜索“希捷硬盘低格工具”或“U盘硬盘复活器”,却发现要么工具不明,要么操作不当造成二次损伤。其实所谓修复工具,本质是U盘启动环境配合硬盘检测与清零软件,低格并非修复物理坏道,而是通过全盘写零触发主控重映射,隔离不稳定扇区。懂原理后,用官方SeaTools、Ventoy/U盘启动盘、Victoria或Linux dd等组合工具,即可对可抢救的硬盘做清零修复。这一技术适用于逻辑坏道、SMART警告、扇区不稳定等场景,但需先备份数据并判断盘体是否有异响

weixin_30431445的博客 217

Ignatius and the Princess II (全排列算法)

Ignatius and the Princess II 题目描述 Problem Description: Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEe...

weixin_43730163的博客 500

随机截距交叉滞后模型RI-CLPM:原理、Mplus实现与结果解读

纵向面板数据分析中,传统交叉滞后模型(CLPM)常被用于探索变量间的时序关系,但其估计结果可能混淆了个体间稳定差异与个体内短期波动,导致交叉滞后路径出现偏差。随机截距交叉滞后模型(RI-CLPM)通过引入随机截距因子,将个体特质层面的差异与个体内动态过程分离,从而提供更纯净的个体内效应估计。该模型在组织心理学、发展心理学、成瘾行为等研究领域迅速普及,并成为顶级期刊审稿时常见的稳健性检验要求。本文从原理出发,系统讲解RI-CLPM的模型构建、识别条件、Mplus实操代码、输出解读及常见陷阱,并结合协变量处理、

weixin_33525298的博客 275

hdoj1027Ignatius and the Princess II(模拟生成字典序排列)

Ignatius and the Princess II<br />Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)<br />Total Submission(s): 1435    Accepted Submission(s): 852<br /><br />Problem DescriptionNow our hero finds the door to the BEelzebub f

独行闹市无人问,青灯剑影响素琴 803

告别ArcGIS小红叉:从‘无法验证登录信息’到成功连接在线资源的完整排错记录

本文详细记录了从Windows便签的网络错误到ArcGIS连接问题的完整排错过程。通过分析代理服务器、DNS配置和系统网络设置,解决了ArcGIS无法验证登录信息的问题,提供了实用的网络优化方案和技术排错思路。

weixin_26800111的博客 390

恒玄BES调试笔记-BES2500如何Dump Anc Audio数据

从YP的4M flash改HP3的2M flash只需要改: 原工程:target.mk的export FLASH_SIZE ?= 0x200000和common.mk里的KBUILD_CPPFLAGS += -DNEW_IMAGE_FLASH_OFFSET=0x100000 OTA工程:target.mk的NEW_IMAGE_FLASH_OFFSET ?= 0x100000和FLASH_SIZE ?= 0x200000 ...

leezs的博客 1672

杭电acm1027(无思路)

ac答案:#include #include using namespace std; int main() { int n, m, p[1005]; while(cin >> n >> m) { for(int i = 0; i < n; i++) p[i] = i + 1; m--; while(m--) { next_permutation(p, p

Aierbude的博客 581

养龙虾之_因特尔UHD/ULtra/Arc核显跑大模型_安装ollama_跑qwen3.5:0.8b/9b_使用copaw1.0.1测试_并配置copaw技能效果炸裂---AI大模型应用探索0019

摘要:本文探讨了利用Intel UHD770核显运行大语言模型的可能性。通过使用Intel发布的ipex-llm项目工具包,成功在核显上运行了Qwen3.5系列模型。测试发现0.8B小模型运行流畅(3-5秒响应),但智能程度有限;而9B大模型虽然效果更好,但响应时间长达2分钟,且GPU/CPU占用率不高。实验证明Intel核显确实可以运行LLM,但实际效果和性能表现仍有提升空间,特别是对大模型的支持尚不理想。

添柴程序猿的专栏 236

hdu 1027 Ignatius and the Princess II(next_permutation())

传送门 题目: Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty Princess. But now the BEelzebub has to beat our hero first. feng5166 says, “I have three question for you, i

Lzhzl211的博客 268

继电保护原理1.2-反时限过流保护

反时限过流保护

让你爱上电路设计 1万+

第6篇:ESP32连接无源喇叭播放音乐《涛声依旧》

相邻两个音之间的倍数是2^(1/12),约等于1.0594630943592952645618252949463)。这样一来,高八度的do频率是低八度do的两倍。我们把频率440赫兹作为中央C ,C调的歌就是把频率440赫兹当作do,乐谱中写作:1=C。一个八度分成12份,八个八度的十二平均音率对应的频率如下(从33Hz到7902Hz)。相邻的两个音之间的差一个半音,12345671之间的间隔分别是“全全半全全全半”。D调的歌就是把从440后面第二个音494赫兹当作do,乐谱中写作1=D。

Txwtech 1424

杭电ACM1027(全排列)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 题目大意:给出一个n和一个m,要求求出数列1,2,3……n的第m个全排列 解题思路:字典序全排列,今天突然发现C++的algorithm函数库里已经实现了求下一个和上一个字典序全排列的函数,于是直接使用next_permutation函数解决。使用方法为:next_permutation(n

Tworld 2569

【Python LeetCode 专题】面试经典 150 题

面试经典 150 题

一杯水果茶!足矣~ 1173

HDU 1027 Ignatius and the Princess II(STL)

Ignatius and the Princess II             Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)                    Total Submission(s): 3392Accepted Submission...

MengDeMao1234的博客 216

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

【STL】hdu 1027 Ignatius and the Princess II

next_permutation函数的应用

Gzbgreat的博客 340

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

HDU 1027 Ignatius and the Princess II【STL- next_permutation全拍列】

题意:输入n和m,求1-n的第m个全排列。 有了STL的next_permutation,妈妈再也不用担心我会WA了。。。

AC_Dreameng 913

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

hdu1027——Ignatius and the Princess II(STL)

题意:1-n的全排列,求字典序第k小的。 思路:这个题还是比较有意思的,也不难,右边x个数的全排列就是x!个,由k的范围,只需要考虑右边8个大数的全排列情况,剩下的小数,先输出就可以,8个数,就可以非常暴力的搞了 然后依次用k/,k%就能知道当前位置应该选择第几小数,然后记得更新,就完了,,最后小心PE。。。 代码: #include&lt;iostream&gt; #include&l...

AAAAAAAC的博客 321

【STL全排列】HDU-1027 Ignatius and the Princess II

注解 1、枚举全排列 2、用STL,next_permutation(数组,数组+长度) 代码 #include <iostream> #include <algorithm> using namespace std; int main() { int n, m; while(cin>>n>>m){ int ...

zhanggirlzhangboy的博客 157

【HDU 1027 Ignatius and the Princess II】+ 全排列 + STL

Ignatius and the Princess IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7832 Accepted Submission(s): 4626Problem Description Now our he

楚江枫 487

HDU 1027 [Ignatius and the Princess II]STL全排列

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 题目大意:求1-N的数列的第M个有序全排列 关键思想:用STL的next_permutation函数。或者康托展开 代码如下: //STL全排列应用 #include <iostream> #include <algorithm> using name...

weixin_30653097的博客 107

【STL相关】hdu 1027 Ignatius and the Princess II【STL】

Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6146    Accepted Submission(s): 3629 Problem Description

mengxiang000000 451

HDU-#1027 Ignatius and the Princess II(全排列+STL)

题目大意:       解题思路:       题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1027       code:

VoidSun 411

hdu1027 Ignatius and the Princess II (全排列 & STL中的神器)

转载请注明出处:http://blog.youkuaiyun.com/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II  Problem Description Now our hero finds the door to the BEe...

weixin_34306446的博客 101

hdu 1027 Ignatius and the Princess II(STL全排列)

Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7117    Accepted Submission(s): 4228 Problem Description

TUT我好菜啊 378

HDU 1027 Ignatius and the Princess II(stl,next_permutation)

HDU 1027 Ignatius and the Princess II 题目:求N个数全排列,顺着数第M个 next_permutation(a,a+n),这是我第一次用这个神奇的函数。以前根本不知道还有这种,能够进行全排列的函数, 与之完全相反的函数还有prev_permutation a[0]=1;a[1]=2;a[2]=3; do{cout << a[0]<< ” ” << a[

银之夏雪的博客 552

hdu 1027 Ignatius and the Princess II (STL 全排列)

题目链接今天学了 全排列函数 之后,再回过头来看这一题,发现这时对于这样的题 就是一个字 秒 。主要函数有两个 next_permutation 和 prev_permutation这两个一个是向后找 一个是向前找,next的是往后,prev的是向前找。有的人可能不太明白我这里只的向前和向后的意思。 向前 就是 往 字典序小 的 方向 找 ,反之 就是向前。             举个例子把

Enstein_Jun 1133
上一篇: HDU - 2899 Strange fuction(三分)
下一篇: csuacm H - 爬楼梯
LangoRow
博客等级 码龄8年 2粉丝 7原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值