Poj 1146 ID Codes + Poj 1833 排列 (全排列库函数)
来源:互联网 发布:动画人物设计软件 编辑:程序博客网 时间:2024/05/16 23:55
很早就用过的东西,昨天遇到题的时候发现忘了函数名怎么拼了。。。。
next_permutation的函数声明:
#include <algorithm>
bool next_permutation( iterator start, iterator end );
The next_permutation() function attempts to transform the given range of elements [start,end) into the next lexicographically greater permutation of elements. If it succeeds, it returns true, otherwise, it returns false.
该函数用于生成给定序列的下一个全排列,成功返回true,会将生成的全排列存储在原数组中,失败,返回false,说明此时当前序列已经是字典序最大的排列了。类似的还有:pre_permutation();用于生成上一个全排列。
非STL实现可以参见:http://blog.csdn.net/dreamvyps/article/details/6067345
Poj 1146 ID Codes
题意描述非常复杂,其实就是判断下一个全排列是否存在。
#include <cstring>#include <string>#include <algorithm>using namespace std;char str[55];int main (){int len;while (~scanf("%s", str),str[0]!='#'){len=strlen(str);if (next_permutation(str,str+len))printf("%s\n", str);else printf("No Successor\n");}return 0;}
#include <string>#include <cstdio>#include <iostream>#include <algorithm>using namespace std; int main (){string str;while (cin >> str){if (str[0]=='#')break;if (next_permutation(str.begin(), str.end()))cout<<str<<endl;elseprintf("No Successor\n");} return 0;}
Poj 1833 排列
详见:http://blog.csdn.net/whyorwhnt/article/details/8652434
- Poj 1146 ID Codes + Poj 1833 排列 (全排列库函数)
- POJ 1146 ID Codes (生成排列)
- [ACM] poj 1146 ID Codes(字符串的下一个排列)
- poj-1146-全排列
- POJ 1833 排列(全排列 STL)
- POJ1146 ID Codes(next_permutation全排列)
- UVA146 POJ1146 ID Codes【全排列】
- poj 1833 排列 库函数 next_permutation 的调用
- POJ 1256 全排列
- 【poj】3187全排列
- POJ-1731 Orders(排序全排列库函数next_permutation())
- poj 1146 ID Codes
- POJ 1146 ID Codes
- poj 1146 ID Codes
- poj 1146 ID Codes
- POJ 1146 ID Codes
- POJ 1146:ID Codes
- poj 1146 ID Codes
- 我的第一篇博客
- plsql 导入dmp文件
- 查询和添加系统联系人
- iPAD越狱后下载破解版的pad软件方法总录
- makefile
- Poj 1146 ID Codes + Poj 1833 排列 (全排列库函数)
- hdu 4419 (线段树 + 扫描线 + 离散化)
- 【91xcz】记录更安全 有道云笔记版新增阅读密码
- Qt关于文件和文件夹的操作
- jsp原理分析 jsp声明和jsp脚本讲解 源码分析 及jsp注释讲解 jsp页面的访问量
- 十大iPhone防盗应用
- Git 版本控制系統(3) 還沒 push 前可以做的事
- JBPM4框架小谈
- Git修改前一次提交的方法(特别注意保持Change-Id不变)