HDU 1027 Ignatius and the Princess II 全排列

PCL 基于超体素的点云分割【2024最新版】 点云超体素分割原理介绍、代码实现以及如何做到将每一个超体素内的点进行单独保存而不造成点云缺失的方法。博客长期更新,本文最近一次更新时间为:2024年12月29日。 阅读详情
题意: 1…n ,求第 m 个全排列

思路:因为,m≤10000,所以只需要求8的全排列, 8!=40320 已经大于10000了,其他的 n>8 全部可以根据 n=8 推出来。我取巧用了STL的next_permutation()函数,万能的STL。

http://acm.hdu.edu.cn/showproblem.php?pid=1027

/*********************************************
    Problem : HDU 1027
    Author  : NMfloat
    InkTime (c) NM . All Rights Reserved .
********************************************/

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define rep(i,a,b)  for(int i = a ; i <= b ; i ++)
#define rrep(i,a,b) for(int i = b ; i >= a ; i --)
#define repE(p,u) for(Edge * p = G[u].first ; p ; p = p -> next)
#define cls(a,x)   memset(a,x,sizeof(a))
#define eps 1e-8

using namespace std;

const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXE = 2e5+5;

typedef long long LL;
typedef unsigned long long ULL;

int T,n,m,k;

int a[10005][9]; //最多只要8个数的全排列

void init() {
    int d[] = {1,2,3,4,5,6,7,8};
    rep(i,1,10000) {
        rep(j,1,8) {
            a[i][j] = d[j-1];
        }
        next_permutation(d,d+8);
    }
}

void input() {

}

void solve() {
    if(n <= 8) {
        int cha = 8 - n;
        rep(i,cha+1,8) {
            printf("%d",a[m][i]-cha);
            if(i == 8) puts("");
            else printf(" ");
        }
    }
    else {
        int cha = n - 8;
        rep(i,1,n-8) printf("%d ",i);
        rep(i,1,8) {
            printf("%d",a[m][i]+cha);
            if(i == 8) puts("");
            else printf(" ");
        }
    }
}   

int main(void) {
    //freopen("a.in","r",stdin);
    //scanf("%d",&T); while(T--) {
    init();
    while(~scanf("%d %d",&n,&m)) {
    //while(scanf("%d",&n),n) {
        input();
        solve();
    }
    return 0;
}
计算机控制技术及应用 《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。 立即下载

相关推荐

rk3588s-摄像头适配gc8034

若还打开失败,需要看下XML中文件配置是否与DTS配置信息一致,或者XML参数配置是否有异常;MIPI摄像头是有上电时序要求,具体时序要查看sensor芯片对应的datasheet进行修改,如果时序不满足,sensor无法正常,此时用i2ctool去查看设备可能无法扫面到设备,即是i2c设备找不到。RK3588或者RK3588S有路MIPI-PHY,驱动开发工程师需要根据对应的硬件原图进行配置,以下会讲解分别使用MIPI-DPHY和MIPI-D/CPHY如何在DTS配置mipi摄像头的回环链路。

Yxx8066的博客 2199

HDU1027 Ignatius and the Princess II【全排列】

Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 11536 Accepted Submission(s): 6640 Problem Description Now our ...

海岛Blog 867

西门子PLC新手必看:200SMART与1200/1500的MODBUS RTU通讯实战(附完整配置流程)

本文详细解析了西门子PLC中S7-200 SMART与S7-1200/1500之间实现MODBUS RTU通讯的完整实战流程。内容涵盖硬件接线、软件配置及程序编写,重点讲解了200SMART作为从站、1200/1500作为主站的典型架构,并提供了关键功能块的使用方法和常见问题排查技巧,帮助新手快速打通不同系列PLC间的数据交换。

weixin_29214559的博客 393

Ignatius and the Princess II(hdu1027全排列)

Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the...

purpleai的博客 259

数字IC物理验证实战 | 从Calibre LVS报告到Innovus定位的Debug全链路解析

本文详细解析了数字IC物理验证中Calibre LVS报告的Debug全流程,从INCORRECT NETS错误的初探到Innovus定位技巧,提供了实战案例和高效工具的使用方法。重点介绍了Calibre高亮功能、Innovus验证命令以及前后端工具联动的关键策略,帮助工程师快速定位和解决LVS问题,提升物理验证效率。

weixin_30919429的博客 127

排队论在食堂窗口规划中的应用:M/M/S模型优化案例

本文通过食堂窗口规划的真实案例,详细阐述了如何运用排队论中的M/M/S模型量化服务效率。文章从问题拆解、数据采集、模型计算到成本效益分析,提供了完整的数学建模实战指南,帮助读者掌握利用最优化方法解决资源配置问题的核心流程与工具。

docker7nomad的博客 1083

hdu1027 Ignatius and the Princess II (全排列)

转载请注明出处: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 BEelzebub ...

2912

别再只盯着CXL协议了,聊聊CXL.mem里那个能动态调优内存性能的‘QoS遥测’到底怎么用

本文深入解析CXL.mem协议中的QoS遥测功能,探讨如何通过DevLoad指标动态调优内存性能。文章详细介绍了QoS遥测的核心机制、多QoS类别设备的实战配置,以及AI训练、金融交易和视频处理场景中的优化案例,帮助数据中心实现高效内存资源管理。

weixin_33725722的博客 436

Ignatius and the Princess II HDU - 1027 全排列

一、内容 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,...

Tizzi的博客 556

ansys命令流力磁耦合仿真

文章目录前言一、力磁耦合仿真流程二、静力学仿真三、力磁耦合模型构建四、静磁学仿真总结 前言 一、力磁耦合仿真流程 力磁耦合有限元仿真流程中,首先进行静力学仿真,经过前处理模块、分析计算模块和后处理模块提取三维模型单元应力,然后根据力磁耦合方程中,通过matlab将单元应力导入到磁导率与应力的关系式中,得到单元的相对磁导率。最后采用载荷传递耦合方式,进行静磁学模拟仿真,分析计算得到该载荷下试件的磁场分布。,如下图所示为力磁耦合仿真流程图: 二、静力学仿真 下图为中心预制条形缺陷的Q235钢板试..

wsfwsf128的博客 2661

霜冰优化算法(RIME)详解:从自然现象到智能优化

霜冰优化算法(RIME)是一种新型元启发式优化算法,灵感源于自然界中霜冰的形成过程。该算法通过模拟软霜和硬霜的不同生长特性,实现了高效的全局探索和局部开发平衡。RIME算法包含三个核心机制:软霜搜索策略模拟随机覆盖特性实现全局探索;硬霜穿刺机制模拟定向生长特性进行局部开发;正向贪婪选择机制确保解的持续优化。与遗传算法、粒子群算法相比,RIME具有参数少、收敛快、自适应平衡等优势,特别适合处理高维复杂优化问题。算法已在工程优化、机器学习等领域获得广泛应用,发表一年内即成为高被引论文。

qq_42212808的博客 780

hdu1027 Ignatius and the Princess II(全排列)

题意:给定两个整数N、M。将1~N排列组合,按字典序从小到大排列,求出排在第M个的排列。 虽然N的范围很大,到1000,1000的阶乘很吓人呀,但是M的范围只到10000,而8的阶乘就已经超过10000了,所以无论N多大,我们最多只要考虑后八位的排列组合问题。 先判断M与阶乘数的大小,确定要考虑后几位的排列组合。假设是考虑后x位的排列组合,先将1~N-x-1顺序输出。然后处理剩余的数:用M对(

Willona_C的博客 583

【数据分析】比较SparCC、Pearson和Spearman相关性估计方法在合成组学数据上的表现

【数据分析】比较SparCC、Pearson和Spearman相关性估计方法在合成组学数据上的表现

专注生信领域 658

HDU1027 Ignatius and the Princess II(全排列)

Ignatius and the Princess IITime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9788    Accepted Submission(s): 5725Problem DescriptionNow our hero ...

BBHHTT的博客 229

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

HDU - 1027 Ignatius and the Princess II 全排列

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

祈的博客 248

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

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

链 接:点击打开链接 题 意:给你两个数n,m,求1 到 m全排列第m小的排列 思 路:全排列的大小是根据它的逆序数的大小 例如 n=5 1 2 3 4 5 逆序数为0 最小 1 2 3 5 4 逆序数为1 ..........

dengjing1200的博客 185

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

【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

【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的博客 156

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

hdu_1027Ignatius 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 BEelzebub has to beat our hero first. feng5166 says, "I have three question for you, if you c

_C9的博客 192

HDU 1027 Ignatius and the Princess II(求第m个全排列)

传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1027 Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 10388    A...

Y先森0.0 145

【全排列】HDU1027Ignatius and the Princess II/HDU1716排列2

全排列函数,666,上次蓝桥杯就沾了全排列的光。。。。 next_pernutation(); 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1716 Problem Description Ray又对数字的列产生了兴趣: 现有四张卡片,用这四张卡片能排列出很多不同的4位数,要求按从小到大的顺序输出这些4位数。

wlxsq的专栏 2188

全排列算法 HDU - 1027 Ignatius and the Princess II

转载自ACM大神:https://blog.youkuaiyun.com/nameofcsdn/article/details/53170690题目:DescriptionNow our hero finds the door to the BEelzebub feng5166. He opens the door and finds feng5166 is about to kill our pretty ...

笑彪夕的博客 604

hdu 1027 Ignatius and the Princess II 全排列

#include int a[1100]; void permutation(int n) { int i,j,k; for(i=n-1;1;i--) if(a[i-1]<a[i])//从后边开始找到第一个比它后面的树小的数 break; j=i-1; for(i=n-1;1;i--) if(a[i]>=a[j])//从后边开始找到不比a[j]小的数 break; k

524

hdu1027 Ignatius and the Princess II 全排列模板题

Ignatius and the Princess IITime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9934    Accepted Submission(s): 5800Problem DescriptionNow our hero ...

popcjz的博客 1805

HDU 1027 Ignatius and the Princess II(全排列)

题意: 对于给定的 1-n的序列,输出第m个全排列 思路: 注意到m最多只有10000,故最多只需要改变末尾的k个,对末尾的k个进行全排列,然后顺序输出//#include <iostream> //#include <cstdio> //#include <string> //#include <cstring> //#include <string.h> //#include <cmath>

宝树啊宝树 529
上一篇: HDU 1026 Ignatius and the Princess I BFS
下一篇: HDU 5596 GTW likes gt 优先队列 BestCoder#66
_NMfloat_
博客等级 码龄12年 7粉丝 315原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值