暴力求解

大致题意 如果一个字符串含有相邻的重复字串称为容易的串,反之为非容易

求字典序第n困难的串……

大致思路,暴力如果是容易的串停过,然后困难的串继续求解tot++

总之先记着吧……

最后输出格式……

uva 129

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <stack>
#include <cctype>
#include <string>
#include <malloc.h>
#include <queue>
#include <map> using namespace std;
const int INF = 0xffffff;
const double esp = 10e-;
const double Pi = * atan(1.0);
const int Maxn = + ;
const int mod = ;
const int dr[] = {,,-,,-,,-,};
const int dc[] = {,,,-,,-,-,};
//int dir2[8][2] = {{-1,0},{0,-1},{-1,1},{1,-1},{-1,-1},{1,0},{0,1},{1,1}}; int n,L;
int a[];
int tot; bool dfs(int cur){
if(tot++ == n){
for(int i = ;i < cur;i++){
if(i && i % == ){
if(i % (*) == ){
cout << endl;
//cout << "$$$$";
}
else
cout << ' ';
}
cout << char(a[i] + 'A');
}
cout << endl;
cout << cur << endl;
return ;
}
for(int i = ;i < L;i++){
a[cur] = i;
bool ok = ;
for(int j = ;j * < cur+;j++){
bool flag = ;
for(int k = ;k < j;k++){
if(a[cur-k] != a[cur-k-j]){
flag = ;
break;
}
}
if(flag){
ok = ;
break;
}
}
if(ok){
if(!dfs(cur+)){
return ;
}
}
}
return ;
} int main()
{
#ifndef ONLINE_JUDGE
freopen("inpt.txt","r",stdin);
#endif
while(cin >> n >> L){
if(!n && !L)
break;
tot = ;
dfs();
}
return ;
}

回家一直在玩,好难过……!!!!

以后要加油……!!!

uva 129的更多相关文章

  1. UVA.129 Krypton Factor (搜索+暴力)

    UVA.129 Krypton Factor (搜索+暴力) 题意分析 搜索的策略是:优先找长串,若长串不合法,则回溯,继续找到合法串,直到找到所求合法串的编号,输出即可. 注意的地方就是合法串的判断 ...

  2. Krypton Factor 困难的串-Uva 129(回溯)

    原题:https://uva.onlinejudge.org/external/1/129.pdf 按照字典顺序生成第n个“困难的串” “困难的串”指的是形如ABAB, ABCABC, CDFGZEF ...

  3. UVa 129 困难的串

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  4. uva 129 krypton factors ——yhx

     Krypton Factor  You have been employed by the organisers of a Super Krypton Factor Contest in which ...

  5. Uva 129 Krypton Factor

    0.这道题的输出 处理起来挺麻烦的 以后类似的可以借鉴一下 ;i<cur;i++) { && i%==) printf("\n%c",a[i]); & ...

  6. UVa 129 Krypton Factor【回溯】

    学习的紫书的回溯,理解起来还是好困难的说啊= = #include<iostream> #include<cstdio> #include<cstring> #in ...

  7. UVa 129 (回溯法) Krypton Factor

    回溯法确实不是很好理解掌握的,学习紫书的代码细细体会. #include <cstdio> ]; int n, L, cnt; int dfs(int cur) { if(cnt++ == ...

  8. UVa 129 Krypton Factor困难的串 (dfs 递归搜索)

    回溯法,只需要判断当前串的后缀,而不是所有的子串 #include<iostream> #include<cstdio> using namespace std; ]; int ...

  9. UVA - 129 Krypton Factor (困难的串)(回溯法)

    题意:求由字母表前L个字母组成的字典序第n小的困难串.(如果一个字符串包含两个相邻的重复子串,则称它是"容易的串",其他串称为"困难的串".) 分析:回溯时,检 ...

随机推荐

  1. 分享,iOS国家手机区号代码.plist

    APP注册需要手机号码的时候,如果有在其他国家的时候需要填写手机区号 一份有国家名字和区号的plist 参照微信注册的时候 格式是 <Array> <Array> <Ar ...

  2. Pascal Analyzer 4 代码分析使用简要说明

    概述 不管在那个开发团队中每个人的编写风格往往是千差万别能力也有高低,如何让别人快速看懂自己的代码维护你的代码.尽量避免不必要的简单错误,为编写代码作一定的约束是必不可少的.如果你说我一个人不需要规范 ...

  3. C++的Json解析库:jsoncpp和boost

    C++的Json解析库:jsoncpp和boost - hzyong_c的专栏 - 博客频道 - CSDN.NET C++的Json解析库:jsoncpp和boost 分类: 网络编程 开源库 201 ...

  4. 保护DNS服务器3大方法

    保护DNS服务器3大方法       DNS全称DomainNameSystem域名解析系统,通俗地说,DNS就是帮助用户在Internet上寻找名称与IP对应的解析服务.为了更方便使用网络资源,DN ...

  5. 利用MySQL 的GROUP_CONCAT函数实现聚合乘法

    MySQL 聚合函数里面提供了加,平均数.最小,最大等,可是没有提供乘法,我们这里来利用MYSQL现有的GROUP_CONCAT函数实现聚合乘法. 先创建一张演示样例表: CREATE TABLE ` ...

  6. INS-30001 ADMIN口令为空

    1.错误描写叙述 2.错误原因 管理口令为空.导致出错 3.解决的方法 填写管理口令和确认口令

  7. 以xml的方式实现动画

    1.java代码 package com.example.tweenanim; import android.os.Bundle; import android.app.Activity; impor ...

  8. CentOS6.5安全策略设置

    应公司内部网站等级测评的需求,正逐渐加强系统安全防护 密码策略设置 检查方法: 使用命令 #cat /etc/login.defs|grep PASS查看密码策略设置 备份方法: cp -p /etc ...

  9. iOS设计模式:观察者

    摘自:http://www.cocoachina.com/applenews/devnews/2013/0506/6132.html 什么是观察者模式什么是观察者模式?你曾经订阅过报纸吗?在订阅报纸的 ...

  10. Ubuntu下安装和配置mysql

    一.检查 1.检查是否已经安装mysql whereis mysql 2.检查mysql服务是否已经启动 sudo netstat -tap | grep mysql 如果没有安装,下面就进行安装. ...