CodeForces 443B Kolya and Tandem Repeat
题目:Click here
题意:给定一个字符串(只包含小写字母,并且最长200)和一个n(表示可以在给定字符串后面任意加n(<=200)个字符)。问最长的一条子串长度,子串满足前半等于后半。
分析:暴力~~~~~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int M = 3e5+; int k;
char str[M];
int ans, len, lenth;
bool check( int x, int y ) { // 判断字符串中[x,y]与[y+1,y-x+1]是否相同
if( x >= len ) return true;
for( int i=x; i<=y; i++ ) {
if( i+lenth >= len ) break;
if( str[i] != str[i+lenth] ) return false;
}
return true;
}
void solve() {
len = strlen( str );
ans = ;
for( int i=; i<len+k-; i++ ) {
for( int j=i; j<len+k; j++ ) {
lenth = j+-i;
if( j+lenth >= len+k ) break;
if( lenth <= ans ) continue;
if( check( i, j ) )
ans = max( ans, lenth );
if( ans == (len+k)/ ) return;
}
}
}
int main() {
while( ~scanf("%s%d", str, &k ) ) {
solve();
printf("%d\n", ans* );
}
return ;
}
CodeForces 443B Kolya and Tandem Repeat的更多相关文章
- Codeforces 443 B. Kolya and Tandem Repeat
		
纯粹练JAVA.... B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megab ...
 - cf443B Kolya and Tandem Repeat
		
B. Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input s ...
 - Kolya and Tandem Repeat
		
 Kolya and Tandem Repeat time limit per test 2 seconds memory limit per test 256 megabytes input s ...
 - codeforces   443 B. Kolya and Tandem Repeat    解题报告
		
题目链接:http://codeforces.com/contest/443/problem/B 题目意思:给出一个只有小写字母的字符串s(假设长度为len),在其后可以添加 k 个长度的字符,形成一 ...
 - CF B. Kolya and Tandem Repeat
		
Kolya got string s for his birthday, the string consists of small English letters. He immediately ad ...
 - Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat
		
本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...
 - Codeforces 443 B Kolya and Tandem Repeat【暴力】
		
题意:给出一个字符串,给出k,可以向该字符串尾部添加k个字符串,求最长的连续重复两次的子串 没有想出来= =不知道最后添加的那k个字符应该怎么处理 后来看了题解,可以先把这k个字符填成'*',再暴力枚 ...
 - Codeforces Round 253 (Div. 2)
		
layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...
 - 33、VCF格式
		
转载:http://blog.sina.com.cn/s/blog_7110867f0101njf5.html http://www.cnblogs.com/liuhui0622/p/6246111. ...
 
随机推荐
- 树型动态规划(树形dp)
			
树型动态规划就是在“树”的数据结构上的动态规划,树型动态规划是建立在树上的,所以有二个方向: 1.根—>叶:这种题目基本上碰不到 2.叶->根:根的子节点传递有用的信息给根,完后根得出最优 ...
 - Maven项目 Spring 单元测试
			
使用maven创建web工程,将Spring配置文件applicationContext.xml放在src/resource下,用eclipse编译时提示class path resource [ap ...
 - zombie-phantom
			
zombie-phantom zombie-phantom Provides a Zombie.js shim around the PhantomJS Headless Browser. npm i ...
 - ubuntu使用crontab
			
crond服务通常被放在/etc/init.d/crond , 这样就可以在系统启动后自动启动crond服务. linux中的用户使用crontab命令来配置cron任务. crontab在/etc目 ...
 - iOS中Block介绍(一)基础
			
ios开发block的使用指南,以及深入理解block的内存管理,也适用于osx开发.讨论范围:block的使用,内存管理,内部实现.不包含的内容:gc arc下的block内存,block在c++中 ...
 - 七日筑基——C#第一天(下)
			
继续C#第一天的内容,昨天我们简单说了一下如何用C#代码来让学生做自我介绍,介绍的格式要求:“我叫威震天,今年20岁,我喜欢踢足球和上网,希望接下来的三年能跟大家一起成长.”威震天介绍完了,继续下一个 ...
 - Node.js笔记2
			
入门二 5. 事件 Node.js中所有的异步I/O操作完成时都会发送一个事件到事件队列. Events 事件模块 `events.EventEmitter` 简单用法: var EventEmitt ...
 - AngularJs 简单入门
			
1.AngularJs 是什么以及应用程序组成的三部分 AngularJS是一个开发动态Web应用的框架.它让你可以使用HTML作为模板语言并且可以通过扩展的HTML语法来使应用组件更加清晰和简洁.它 ...
 - 注册表缺失导致Windows Server 2008 R2时钟服务W32time不能自启
			
参照@飘云 http://blog.csdn.net/piaoyunqing/article/details/6323647 的文章. 测试环境中有一台Windows Server 2008 R2的虚 ...
 - HDOJ 1166.敌兵布阵
			
2015-06-08 问题简述: 原题的题意相当于有一些连续摆放的箱子,里面装着球,球的数量可以加减,现要查询几个连续的箱子里球的总数,其中存在放球和拿球的操作. 原题链接:http://acm.hd ...