Brute Force & STL --- UVA 146 ID Codes
| ID Codes |
Problem's Link:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=3&problem=82&mosmsg=Submission+received+with+ID+14418598
Mean:
求出可重排列的下一个排列。
analyse:
直接用STL来实现就可。自己手动写了一个,并不复杂。
Time complexity: O(n^2)
Source code:
1.STL
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
char s[55];
while(scanf("%s",s)!=EOF)
{
if(s[0]=='#') break;
if(next_permutation(s,s+strlen(s))) printf("%s\n",s);
else printf("No Successor\n");
memset(s,0,sizeof(s));
}
return 0;
}
2.手写
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
//freopen("a.txt","r",stdin);
char s[55];
while(scanf("%s",s),s[0]!='#')
{
int i,j,len(strlen(s));
for(i=len-2; i>=0; i--)
if(s[i]<s[i+1])
break;
if(i<0) puts("No Successor");
else
{
for(j=i+1; i<len; j++)
if(s[i]>=s[j])
{
char c=s[i];
s[i]=s[j-1];
s[j-1]=c;
break;
}
sort(s+i+1,s+len);
puts(s);
}
}
return 0;
}
Brute Force & STL --- UVA 146 ID Codes的更多相关文章
- UVA 146 ID Codes(下一个排列)
C - ID Codes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Statu ...
- nginx 1.3.9/1.4.0 x86 Brute Force Remote Exploit
测试方法: 本站提供程序(方法)可能带有攻击性,仅供安全研究与教学之用,风险自负! #nginx 1.3.9/1.4.0 x86 brute force remote exploit # copyri ...
- poj 1146 ID Codes (字符串处理 生成排列组合 生成当前串的下一个字典序排列 【*模板】 )
ID Codes Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 6229 Accepted: 3737 Descript ...
- uva146 ID codes
Description It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In or ...
- 小白日记46:kali渗透测试之Web渗透-SqlMap自动注入(四)-sqlmap参数详解- Enumeration,Brute force,UDF injection,File system,OS,Windows Registry,General,Miscellaneous
sqlmap自动注入 Enumeration[数据枚举] --privileges -U username[CU 当前账号] -D dvwa -T users -C user --columns [ ...
- HDU 4971 A simple brute force problem.
A simple brute force problem. Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged o ...
- DVWA实验之Brute Force(暴力破解)- High
DVWA实验之Brute Force(暴力破解)- High 有关DVWA环境搭建的教程请参考: https://www.cnblogs.com/0yst3r-2046/p/10928380.ht ...
- DVWA实验之Brute Force(暴力破解)- Low
DVWA实验之Brute Force-暴力破解- Low 这里开始DVWA的相关实验~ 有关DVWA环境搭建的教程请参考: https://www.cnblogs.com/0yst3r-2 ...
- SRM 582 Div II Level Three: ColorTheCells, Brute Force 算法
题目来源:http://community.topcoder.com/stat?c=problem_statement&pm=12581 Burte Force 算法,求解了所有了情况,注意 ...
随机推荐
- Scala 深入浅出实战经典 第64讲:Scala中隐式对象代码实战详解
王家林亲授<DT大数据梦工厂>大数据实战视频 Scala 深入浅出实战经典(1-87讲)完整视频.PPT.代码下载:百度云盘:http://pan.baidu.com/s/1c0noOt6 ...
- icmp,tcp,traceroute,ping,iptables
有东莞的监控主机到北京BGP出问题了: 报警短信疯狂发送: 找东莞IDC和北京BGP服务商协查: 有个奇怪的问题:北京到东莞trcaceroute都有路由信息 东莞143段到北京全无路由信息:但,东莞 ...
- 【Python】winpython下的包安装
1.安装easy_install http://blog.csdn.net/A8572785/article/details/10945237 2.与ipython兼容的ipdb命令 pip inst ...
- FoLlow 的技术博客
酷壳 http://coolshell.cn 老赵点滴- 追求编程之美 http://blog.zhaojie.me/ Pixel-In-Gene Blog
- 使用 ContentProviderOperation 来提升性能
ContentProviders 是android 系统核心组件之一,ContentProviders 封装了数据的访问接口,其底层数据一般都是保存在数据库中或者保存在云端. 有时候你需要更新多行数 ...
- 《objective-c基础教程》学习笔记(十)—— 内存管理
本篇博文,将给大家介绍下再Objective-C中如何使用内存管理.一个程序运行的时候,如果不及时的释放没有用的空间内存.那么,程序会越来越臃肿,内存占用量会不断升高.我们在使用的时候,就会感觉很卡, ...
- 读写文本(.txt)文件 .NET
http://www.cnblogs.com/jx270/archive/2013/04/14/3020456.html (一) 读取文件 如果你要读取的文件内容不是很多,可以使用 File.Read ...
- win8 IIS
IIS打开页面报500错误 aspnet_regiis.exe -i 报 “此操作系统版本不支持此选项” 决解方法: 控制面板 - 程序和功能 - 启动或关闭windows功能 - Internet ...
- Python--将内容写入文本文件中
#-*- coding: utf-8 -*- import sys __cfg__version__ = 'debug' # release if __name__ == '__main__': pr ...
- Adobe flash player更新失败