51nod 1348【next_permutation】
next_permutation的粗讲来自窝bin博客
两个重载函数,第二个带谓词参数_Comp,其中只带两个参数的版本,默认谓词函数为”小于”.
返回值:bool类型
分析next_permutation函数执行过程:
假设数列 d1,d2,d3,d4……
范围由[first,last)标记,调用next_permutation使数列逐次增大,这个递增过程按照字典序。
next_permutation在algorithm头文件里,可以用它来生成全排列。
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=10;
char a[N];
int main()
{
int len;
scanf("%s",a);
len=strlen(a);
sort(a,a+len);
printf("%s\n",a);
while(next_permutation(a,a+len))
printf("%s\n",a);
return 0;
}
51nod 1348【next_permutation】的更多相关文章
- HDU 3485【101】 51nod 1668【010】 joj 2171【111】动态规划
有一个只含0和1的长度为n的串,问不含有101的所有串的个数. ——不存在连续的101.010.111的字符串数量 HDU:https://cn.vjudge.net/problem/HDU-3485 ...
- 51nod 1051【基础】
思路: 找题4级做做...然后找了题最水的.. = =感动...居然是一下子[记]得了做法... dp一下,枚举列的起点和终点,然后求和这一段,然后对这一大列就是求个最大字段和: #include & ...
- HDU1027 Ignatius and the Princess II 【next_permutation】【DFS】
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ( ...
- 51nod 1354【DP】
(我一定是A了一题假DP) 给定序列a[0],a[1],a[2],...,a[n-1] 和一个整数K时, 有多少子序列所有元素乘起来恰好等于K. K<=1e8; 思路: 感觉 k 的 约数是突破 ...
- 51nod 1154【DP】
区间DP大暴力吧?GG. dp[ i ] 为字符至 i 的最少数量. 如果[Left , Right]是回文串, dp[Right] = min(dp[ Right ] , dp[Left-1] + ...
- 51nod 1405【DFS】
思路: 对于结点 u 的子节点 v, 如果已经一直到结点 u 的答案ans[u],那么转移到对于结点 v,num[v] 为 v为根的树的结点个数,那么对于结点v的答案相对于结点u的答案来说, ans[ ...
- 51nod 1099【贪心】
思路: 我们可以思考对于仅仅两个元素来说,A,B; 先选A的话是会 A.b+B.a; 先选B的话是会 B.b+A.a; 所以哪个小哪个就放前面; #include <cstdio> #i ...
- 51nod 1049【经典】
自己模拟,全靠体会~ #include <cstdio> #include <stack> #include <iostream> #include <str ...
- 51nod 1416【DFS】
思路: 暴力整个图,以这个为起点,然后看一下有没有找到一条路是会指向自己且元素个数>=4: #include <bits/stdc++.h> using namespace std; ...
随机推荐
- android lanchmode
http://www.cnblogs.com/xiaoQLu/archive/2012/07/17/2595294.html http://www.cnblogs.com/lwbqqyumidi/p/ ...
- EasyDarwin EasyClient开源流媒体播放器,支持多窗口显示
EasyDarwin开源团队开源的EasyClient客户端将支持流媒体采集.编码.推送.播放.抓图.录像.Onvif 等全套功能(大家持续关注我们Github的commit),其中播放功能是开源流媒 ...
- iOS应用的入口自定义和事件处理的自定义
iOS应用的入口自定义和事件处理的自定义 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: ...
- Whats the difference between service tomcat ./startup.sh and ./catalina.sh run
stack overflow 给出的答案: catalina.sh run starts tomcat in the foreground, displaying the logs on the co ...
- POJ1061 青蛙的约会 —— 扩展gcd
题目链接:https://vjudge.net/problem/POJ-1061 青蛙的约会 Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- Codeforces Round #407 (Div. 1) B. Weird journey —— dfs + 图
题目链接:http://codeforces.com/problemset/problem/788/B B. Weird journey time limit per test 2 seconds m ...
- 从Github上下载了项目,导入Android Studio,gradle 报错,应该怎么修改
一.从Github上获取源代码 我这里是直接下载ZIP文件 二.在本机的Android Studio上新建一个空白项目,目的主要是与刚从Github上下载的项目文件结构做对比 三.替换gradle文件 ...
- elasticsearch function_score Query——文档排序结果的最后一道墙
function_score Query The function_score query is the ultimate tool for taking control of the scoring ...
- nginx + ffmpeg
第一种方案:ffmpeg+nginx 新的ffmpeg已经支持HLS.(本人也参与了代码供献,给自己做个广告:)) 点播: 生成hls分片: ffmpeg -i <媒体文件> -c:v l ...
- 提高scroll性能
在DevTools中开始渲染,向下滑动一点点滚动条,然后停止滚动. 在结果中,注意frames总是在30ftps线上面,甚至都木有很接近69ftps线的(事实上帧执行的太缓慢以致于60ftps线在图上 ...