POJ 3049 DFS
思路:暴搜
//By SiriusRen
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int l,c,yuan,fu,lenth;
char a[16],s[16];
bool Yuan(char x){
if(x=='a'||x=='e'||x=='i'||x=='o'||x=='u')return 1;
return 0;
}
void dfs(int x){
if(lenth==l){
if(yuan&&fu>=2)printf("%s\n",s+1);
return;
}
for(int i=x;i<=c;i++){
lenth++;
if(Yuan(a[i]))yuan++;
else fu++;
s[lenth]=a[i];
dfs(i+1);
lenth--;
if(Yuan(a[i]))yuan--;
else fu--;
}
}
int main(){
scanf("%d%d",&l,&c);
for(int i=1;i<=c;i++)cin>>a[i];
sort(a+1,a+1+c);
dfs(1);
}
POJ 3049 DFS的更多相关文章
- POJ 1321 DFS
题意:POJ少见的中文题,福利啊. 思路: 一开始也没有思路呃呃呃 . 裸搜,连样例都过不去...参照了网上的题解:一行一行DFS 茅塞顿开啊. #include <cstdio> #in ...
- POJ 1979 dfs和bfs两种解法
fengyun@fengyun-server:~/learn/acm/poj$ cat 1979.cpp #include<cstdio> #include<iostream&g ...
- poj 1190 DFS 不等式放缩进行剪枝
F - (例题)不等式放缩 Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64u Submi ...
- poj 1562 dfs
http://poj.org/problem?id=1562 #include<iostream> using namespace std; ,m=,sum=; ][]; ][]={-,, ...
- POJ 1979 DFS
题目链接:http://poj.org/problem?id=1979 #include<cstring> #include<iostream> using namespace ...
- poj 1088 (dfs+记忆化) 滑雪
题目;http://poj.org/problem?id=1088 感觉对深搜还不太熟练,所以练习一下,类似于连连看的那题,注意的是所求的是最大达长度,并不是从最大的或者最小的点出发得到的就是最长的路 ...
- Oil Deposits(poj 1526 DFS入门题)
http://poj.org/problem?id=1562 ...
- POJ 3414 dfs 回溯
题目链接:http://poj.org/problem?id=3414 题意:三个值A, B, C, A和B是两个杯子的容量,问最短操作数使A或者B里的水量是C.有三种操作. 思路:dfs.暴力 很简 ...
- poj 2531(dfs)
题目链接:http://poj.org/problem?id=2531 思路:由于N才20,可以dfs爆搞,枚举所有的情况,复杂度为2^(n). #include<iostream> #i ...
随机推荐
- win10安装jdk8 配置环境变量
参考:https://jingyan.baidu.com/article/6b97984dd257b41ca2b0bf86.html
- pip源
阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/ 豆瓣(do ...
- vue-cli生成的模板各个文件详解(转)
vue-cli脚手架中webpack配置基础文件详解 一.前言 原文:https://segmentfault.com/a/1190000014804826 vue-cli是构建vue单页应用的脚手架 ...
- JavaScript 回车键绑定登录 事件 常用键位码(keyCode)
1.回车键绑定登录事件 $(document).keydown(function (e) { if ((e.keyCode || e.which) == 13) { //document.queryS ...
- CodeForces 383C Propagating tree
Propagating tree Time Limit: 2000ms Memory Limit: 262144KB This problem will be judged on CodeForces ...
- ios 文件上传, post数据
转自:http://www.maxiaoguo.com/clothes/267.html 一.文件下载 获取资源文件大小有两张方式 1. HTTP HEAD方法 NSMutableURLRequest ...
- mysql二进制日志文件出错导致mysql服务无法启动
今天打开phpmyadmin发现连不上mysql数据库,重新启动mysql启动不起来,查看日志发现例如以下错误 <span style="font-family:SimSun;font ...
- Mysql之索引的基本概念
一.索引是什么? 比如我们要在字典中找某一字,如何才能快速找到呢?那就是通过字典的目录. 对数据库来说,索引的作用就是给‘数据’加目录. 二.索引算法 设有N条随机记录,不用索引,平均查找N/2次,那 ...
- quartz-misfire 错失、补偿执行
调度(scheduleJob)或恢复调度(resumeTrigger,resumeJob)后不同的misfire对应的处理规则 misfire产生的条件是:到了该触发执行时上一个执行还未完成,且线程池 ...
- Java反射异常处理之InvocationTargetException
java.lang.reflect.InvocationTargetException处理办法可能是没有引commons-lang3-3.x.jar包