Codeforces Round #253 (Div. 2)B(暴力枚举)
就暴力枚举所有起点和终点就行了。
我做这题时想的太多了,最简单的暴力枚举起始点却没想到。。。应该先想最简单的方法,层层深入。
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;
#define INF 1000000000
#define eps 1e-8
#define pii pair<int,int>
#define LL long long int
char s[];
int k,ans;
void check(int b,int e)
{
int l=e-b+;
if(l&) return;
else
{
int t=l/;
for(int i=b;i<b+t;i++)
{
if(s[i]==s[t+i]||s[t+i]==)
continue;
else return;
}
ans=max(ans,l);
return;
}
}
int main()
{
//freopen("in7.txt","r",stdin);
//freopen("out.txt","w",stdout);
scanf("%s",s);
scanf("%d",&k);
int len=strlen(s);
int lens=len+k;
ans=;
for(int i=;i<lens-;i++)
{
for(int j=i+;j<=lens-;j++)
{
check(i,j);
}
}
printf("%d\n",ans);
//fclose(stdin);
//fclose(stdout);
return ;
}
Codeforces Round #253 (Div. 2)B(暴力枚举)的更多相关文章
- Codeforces Round #258 (Div. 2)C(暴力枚举)
就枚举四种情况,哪种能行就是yes了.很简单,关键是写法,我写的又丑又长...看了zhanyl的写法顿时心生敬佩.写的干净利落,简直美如画...这是功力的体现! 以下是zhanyl的写法,转载在此以供 ...
- Codeforces Round 253 (Div. 2)
layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round #253 (Div. 1) (A, B, C)
Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...
- Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力
A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...
- Codeforces Round #253 (Div. 2) D题
题目大意是选出一个其他不选,问问最大概率: 刚开始想到DP:F[I][J][0]:表示从 前I个中选出J个的最大值, 然后对于F[I][J][1]=MAX(F[I-1][J][1],F[I-1][J- ...
- Codeforces Round #426 (Div. 2)【A.枚举,B.思维,C,二分+数学】
A. The Useless Toy time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Round #253 (Div. 2) D. Andrey and Problem
关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...
- Codeforces Round #363 (Div. 2) B 暴力
Description You are given a description of a depot. It is a rectangular checkered field of n × m siz ...
- Codeforces Round #253 (Div. 2)——Borya and Hanabi
题目连接 题意: n表示有n个卡片.每一个卡片有一种颜色和一个数字(共五种不同的颜色和五个不同的数字). 事先知道每种卡片有几张.可是不知道详细的位置. 问须要几次提示就能够知道全部卡片的位置都在哪里 ...
随机推荐
- 2.5 使用ARDUINO做主控,手机发送短信控制开关LED
需要准备的硬件 MC20开发板 1个 https://item.taobao.com/item.htm?id=562661881042 GSM/GPRS天线 1根 https://item.taoba ...
- Way to OpenSource
@1:Follow any instructions in the readme and make sure that you can configure and run the project on ...
- 数字代币ICO
随着比特币.莱特币.以太币的逐步兴起,越来越多的数字代币开始衍生,虚拟货币扑朔迷离,一不小心就被人割了韭菜..... 从荷兰IPO的故事说起 400多年前,西方有一群精英海盗开了一家公司.为了顺利拓展 ...
- Qt发布程序
一.作用 将Qt软件打包发布成绿色exe,在任意非Qt环境下运行 二.找到我们软件所依赖动态库 使用Qt的windeployqt.exe(在Qt安装目录的bin下面找)--! 1.新建文件夹,在里面放 ...
- C++11 里lambda表达式的学习
最近看到很多关于C++11的文档,有些是我不怎么用到,所以就略过去了,但是lambda表达式还是比较常用的,其实最开始学习python的时候就觉得lambda这个比较高级,为什么C++这么弱.果然C+ ...
- IntelliJ IDEA 中 右键新建时,选项没有Java class的解决方法和具体解释
我是在别人问我的时候,才发现还可以有这个问题,主要是他新项目直接打开,什么都没配置,就打算新建文件,其实可以直接看编辑器右下角的event log,那个对话框点开的话,可以add as maven p ...
- SpringMVC中响应json数据(异步传送)
1.首先导入3个jar包: jackson-annotations-2.1.5.jar jackson-core-2.1.5.jar jackson-databind-2.1.5.jar JSON所需 ...
- Shell脚本报错--syntax error near unexpected token for((i=0;i<$length;i++))
现象: shell脚本使用Nodepad++进行本地编辑,在编辑后上传到linux机器进行执行时提示“syntax error near unexpected token for((i=0;i< ...
- Linux ls命令参数详解
-a -- 全部(all).列举目录中的全部文件,包括隐藏文件(.filename).位于这个列表的起首处的 .. 和 . 依次是指父目录和你的当前目录. -l -- 长(long).列举目 ...
- dubbox 学习
目录 编译源码 发布dubbo的jar包到私库 安装dubbo-admin 安装monitor Springboot+dubbox 其他 编译源码 dubbox是没有安装包的,所以我们只能先下载源码 ...