Sicily 4495. Print permutations
按字典序生成字符串的全排列
直接递归:
#include <iostream>
#include <string>
#include <cstring> using namespace std; int len;
bool ever[9];
string str; void permutation(string cur)
{
if(cur.size() == len)
{
cout<<cur<<endl;
return ;
}
for(int i=0;i<len;++i)
{
if(!ever[i])
{
ever[i] = 1;
permutation(cur + str[i]);
ever[i] = 0;
}
}
} int main()
{
while(cin>>str)
{
memset(ever,0,sizeof(ever));
len = str.size();
permutation("");
}
return 0;
}
Sicily 4495. Print permutations的更多相关文章
- python 生成排列、组合以及选择
from <python cookbook> 19.15 任务 需要对一个序列的排列(permutation).组合(combination)或选择(selection)进行迭代操作.即使 ...
- python迭代器Itertools
https://docs.python.org/3.6/library/itertools.html 一无限迭代器: Iterator Arguments Results Example count( ...
- python实现经典算法
1,快速排序 题目形式:手写一下快速排序算法. 题目难度:中等. 出现概率:约50%.手写快排绝对是手撕代码面试题中的百兽之王,掌握了它就是送分题,没有掌握它就是送命题. 参考代码: def quic ...
- Python笔试——毕业旅行问题
毕业旅行问题 小明目前在做一份毕业旅行的规划.打算从北京出发,分别去若干个城市,然后再回到北京,每个城市之间均乘坐高铁,且每个城市只去一次.由于经费有限,希望能够通过合理的路线安排尽可能的省一些路上的 ...
- 【leetcode】Permutations
题目描述: Given a collection of numbers, return all possible permutations. For example, [1,2,3] have the ...
- 大数求模 sicily 1020
Search
- uva11630 or hdu2987 Cyclic antimonotonic permutations(构造水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Cyclic antimonotonic permutations Time Li ...
- [Leetcode][Python]47: Permutations II
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 47: Permutations IIhttps://oj.leetcode. ...
- [Leetcode][Python]46: Permutations
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 46: Permutationshttps://leetcode.com/pr ...
随机推荐
- android基础4——Mainifest
众所周知,应用程序中的每一个UI都是通过Activity类的一个或者多个拓展实现的.在桌面开发环境中,Activity相当于Form,来布局和显示信息,以及影响用户的动作.Mainifest可以定义应 ...
- [置顶] 实习总结3-job hunting(西安工作)
开始整理关于西安top level的IT企业的工作从去年开始实习就慢慢展开了,到了北京之后一直关注的比较密切,因此前前后后也整理了很多.本来不打算那么急着写这一篇的,但是在因为在公司呆着,对于西安的一 ...
- 学习Emacs系列教程
emacs最简单入门,只要10分钟 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 3 ...
- GLFW库文件配置
VS2012+windows8下面,vs的默认路径在C:\Program Files(x86)\Windows Kits\8.0 下. 将include\GLFW里.h文件加入vs路径Include\ ...
- 开源DirectShow分析器和解码器: LAV Filter
LAV Filter 是一款开源的DirectShow视频分离和解码软件,他的分离器LAVSplitter封装了FFMPEG中的libavformat,解码器LAVAudio和LAVVideo则封装了 ...
- javascript实现小九九乘法口诀
<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/h ...
- vmlinux,vmlinuz,bzimage,zimage,initrd.img的区别与联系
1.vmlinux vmlinux是未压缩的内核,vmlinux 是ELF文件,即编译出来的最原始的文件.用于kernel-debug,产生system.map符号表,不能用于直接加载,不可以作为启动 ...
- JFreeChat
JFreeChart教程(一) 分类: java Component2007-05-31 15:53 39849人阅读 评论(30) 收藏 举报 jfreechartimportdataset图形ap ...
- 《think in python》学习-5
think in python -5 think in python -5 条件和递归 求模操作符% 用于整数,可以计算出第一个操作数除以第二个操作数的余数 7%3 #结果是2 求模操作符%有很多用途 ...
- TCP应用编程--套接字C#实现
套接字之间的连接过程可以分为三个步骤: 1.服务器监听 2.客户端请求 3.连接确认 Ø服务器监听:是指服务器套接字并不定位具体的客户端套接字,而 是处于等待连接的状态,实时监控网络状态. Ø客户端 ...