UVa 628 - Passwords
来源:互联网 发布:微赞淘宝客浏览器失败 编辑:程序博客网 时间:2024/04/28 19:49
题目:给你一个单词的字典,一个由0与#组成的字符串,0代表数字0-9,#代表字典中的单词;
输出所有的0#串的表示方式,统一句子中的#代表一个单词。
分析:搜索。打表计算出所有的数字的排列情况,然后枚举输出即可。
说明:P(10,7)当成P(7,7)数字开小了,RE了好几次。
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <cmath>using namespace std;char words[111][300],rule[300];int buf[605000][11],save[11],number;void dfs(int d, int n){if (d == n) {for (int i = 0 ; i < n ; ++ i)buf[number][i] = save[i];number ++;return;}for (int i = 0 ; i < 10 ; ++ i) {save[d] = i;dfs(d+1, n);save[d] = i;}}int main(){int n,m; while (~scanf("%d",&n)) {for (int i = 0 ; i < n ; ++ i)scanf("%s",words[i]);scanf("%d",&m);printf("--\n");for (int i = 0 ; i < m ; ++ i) {scanf("%s",rule);int count = 0;for (int j = 0 ; rule[j] ; ++ j)count += (rule[j]=='0');number = 0;dfs(0, count);for (int j = 0 ; j < n ; ++ j)for (int p = 0 ; p < number ; ++ p) {for (int deep = 0,k = 0 ; rule[k] ; ++ k) {if (rule[k] == '#')printf("%s",words[j]);if (rule[k] == '0') printf("%d",buf[p][deep ++]);}printf("\n");}}} return 0;}
0 0
- UVa 628 - Passwords
- Passwords
- B. Passwords
- Chrome passwords
- get Firefox Passwords
- Encoding Passwords with Acegi
- zoj 2514 Generate Passwords
- ZOJ 2514Generate Passwords
- ZOJ 2514 Generate Passwords
- Sicily 13460. Passwords
- zoj2514 Generate Passwords
- osgeo default passwords
- CodeForces 721B Passwords
- codeforces 721 Passwords
- zoj 2514 Generate Passwords 水题
- ZOJ 2514 Generate Passwords 水
- USACO5.5.2 Hidden Passwords (hidden)
- Running LAPS Around Cleartext Passwords
- Oracle EBS数据定义移植工具:FNDLOAD
- Nc57二次开发合同先进先出
- CDbCriteria 详细便用说明
- sin和圆形弧度制的表示
- Java中如何封装自己的类,建立并使用自己的类库?
- UVa 628 - Passwords
- 【leetcode-1】Two Sum
- YII 快速创建项目GII
- canal安装部署
- eclipse调试 Red5 项目时查看 Red5 容器内部运行机制
- ios学习之UITableView(一)
- Javascript 面向对象编程(一):封装
- out类类型数组
- 找不到答案的时候,就独自出去看一看这个世界