思路:暴搜

//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的更多相关文章

  1. POJ 1321 DFS

    题意:POJ少见的中文题,福利啊. 思路: 一开始也没有思路呃呃呃 . 裸搜,连样例都过不去...参照了网上的题解:一行一行DFS 茅塞顿开啊. #include <cstdio> #in ...

  2. POJ 1979 dfs和bfs两种解法

      fengyun@fengyun-server:~/learn/acm/poj$ cat 1979.cpp #include<cstdio> #include<iostream&g ...

  3. poj 1190 DFS 不等式放缩进行剪枝

    F - (例题)不等式放缩 Time Limit:1000MS     Memory Limit:10000KB     64bit IO Format:%I64d & %I64u Submi ...

  4. poj 1562 dfs

    http://poj.org/problem?id=1562 #include<iostream> using namespace std; ,m=,sum=; ][]; ][]={-,, ...

  5. POJ 1979 DFS

    题目链接:http://poj.org/problem?id=1979 #include<cstring> #include<iostream> using namespace ...

  6. poj 1088 (dfs+记忆化) 滑雪

    题目;http://poj.org/problem?id=1088 感觉对深搜还不太熟练,所以练习一下,类似于连连看的那题,注意的是所求的是最大达长度,并不是从最大的或者最小的点出发得到的就是最长的路 ...

  7. Oil Deposits(poj 1526 DFS入门题)

    http://poj.org/problem?id=1562                                                                       ...

  8. POJ 3414 dfs 回溯

    题目链接:http://poj.org/problem?id=3414 题意:三个值A, B, C, A和B是两个杯子的容量,问最短操作数使A或者B里的水量是C.有三种操作. 思路:dfs.暴力 很简 ...

  9. poj 2531(dfs)

    题目链接:http://poj.org/problem?id=2531 思路:由于N才20,可以dfs爆搞,枚举所有的情况,复杂度为2^(n). #include<iostream> #i ...

随机推荐

  1. Example of working with a dump.

    Let's say that you are looking at a crash dump, so following the first command from this page you do ...

  2. DNS Prefetching

    For Developers‎ > ‎Design Documents‎ > ‎ DNS Prefetching 目录 1 Problem 2 Solution 3 Architectur ...

  3. perl JSON模块使用

    简介: JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式. 它基于JavaScript(Standard ECMA-262 3rd Edition - De ...

  4. 紫书 习题 10-15 UVa 12063(数位dp)

    大佬真的强!!https://blog.csdn.net/u014800748/article/details/45225881 #include<cstdio> #include< ...

  5. Spring学习总结(12)——Druid连接池及监控在spring配置

    Druid连接池及监控在spring配置如下: <bean id="dataSource" class="com.alibaba.druid.pool.DruidD ...

  6. CCNP路由实验之九 路由策略

     CCNP路由实验之九 路由策略 路由器在公布与接收路由信息时,可能须要实施一些策略.以便对路由信息进行过滤,比如仅仅接收或公布满足一定条件的路由信息. 一种路由协议可能须要引入其它的路由协议发现 ...

  7. hdu2795Billboard(线段树,找第一个大于w的点)

    Billboard Time Limit: 20000/8000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  8. 为OLED屏添加GUI支持2:2D图形库

    为OLED屏添加GUI支持2:2D图形库 本文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 环境: 主机:WIN10 开发环境:MDK5.13 MCU:S ...

  9. 【LeetCode-面试算法经典-Java实现】【032-Longest Valid Parentheses(最长有效括号)】

    [032-Longest Valid Parentheses(最长有效括号)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a string contai ...

  10. spring配置 quartz-config.xml

    <!-- 配置调度程序quartz ,其中配置JobDetail有两种方式--> <!-- 使用MethodInvokingJobDetailFactoryBean,任务类可以不实现 ...