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 ...
随机推荐
- springmvc 1.接受日期类型的参数 2.后台返回json串的格式处理(返回json串null值处理为"")
springmvc中的配置: <bean id="dateConvert" class="com.iomp.util.DateConvert"/> ...
- ItemTouchHelper(实现RecyclerView上添加拖动排序与滑动删除的所有事情)
简单介绍: ItemTouchHelper是一个强大的工具,它处理好了关于在RecyclerView上添加拖动排序与滑动删除的所有事情.它是RecyclerView.ItemDecoration的子类 ...
- 使用google API之前需要對input 做什麼 安全性的處理?
我正要使用node.js 和 google map api做一个小应用,Google MAP API的使用URL如下: https://maps.googleapis.com/maps/api/pla ...
- Spring AOP 实现数据库读写分离
背景 我们一般应用对数据库而言都是"读多写少",也就说对数据库读取数据的压力比较大,有一个思路就是说采用数据库集群的方案, 其中一个是主库,负责写入数据,我们称之为:写库: 其它都 ...
- [转] -- html5手机网站自适应需要加的meta标签
webapp开发初期,会碰到在pc端开发好的页面在移动端显示过大的问题,这里需要在html head中加入meta标签来控制缩放 <meta name=" viewport" ...
- HDU-2303 The Embarrassed Cryptographer 高精度算法(大数取模)
题目链接:https://cn.vjudge.net/problem/HDU-2303 题意 给一个大数K,和一个整数L,其中K是两个素数的乘积 问K的是否存在小于L的素数因子 思路 枚举素数,大数取 ...
- 解决zabbix容器中文无法选择的问题
1.查看zabbiz-web运行的容器 2.进入容器 3.安装语言包(针对centos7) yum install -y kde-l10n-chinese 4.更新gitbc包(因为镜像阉割了该包的部 ...
- ECNUOJ 2150 完美的拯救
完美的拯救 Time Limit:1000MS Memory Limit:65536KBTotal Submit:147 Accepted:50 Description 一只可怜的蚂蚁被万恶的魔术师 ...
- CodeForces 337A Puzzles
Puzzles Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Origina ...
- HDU——T 3342 Legal or Not
http://acm.hdu.edu.cn/showproblem.php?pid=3342 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...