String Typing CodeForces - 954B
题意:
给一个字符串,可以复制某一段字符,问最少需要多少步能将其输出,比如abcabcd,先输入abc然后再赋值abc再输入d就只需要5步。
复制的这段字符 必须是从字符串的0位置开始复制的 而且只能粘贴一次 例abcabcabc 输出为7
emm。。。
str.substr(i,j) 截取字符串str第i位置开始的长度为j的一段字符
#include <bits/stdc++.h> //freopen("1.txt", "r", stdin); using namespace std; const int maxn = 10010, INF = 0x7fffffff;int main() {int n;string str;cin>> n >> str;int res = n;for(int i=1; i<=n/2; i++)if(str.substr(0, i) == str.substr(i, i)) res = n - i + 1;cout<< res <<endl;return 0; }
转载于:https://www.cnblogs.com/WTSRUVF/p/9405096.html
String Typing CodeForces - 954B相关推荐
- Binary String Reconstruction CodeForces - 1352F(思维+构造)
For some binary string s (i.e. each character si is either '0' or '1'), all pairs of consecutive (ad ...
- Binary String Minimizing CodeForces - 1256D(贪心)
You are given a binary string of length n (i. e. a string consisting of n characters '0' and '1'). I ...
- String Modification CodeForces - 1316B(规律)
Vasya has a string s of length n. He decides to make the following modification to the string: Pick ...
- A Perfectly Balanced String?(Codeforces Round #785 (Div. 2))
A Perfectly Balanced String? Let's call a string s perfectly balanced if for all possible triplets ( ...
- CodeForces - 1535C Unstable String(思维)
题目链接:点击查看 题目大意:规定一个字符串将问号都替换成 000 或 111 后满足 010101 交替的话,该字符串是合法的,现在给出一个长度为 nnn 的字符串,求合法子串的个数 题目分析:两种 ...
- CodeForces - 1506G Maximize the Remaining String(单调栈+贪心)
题目链接:点击查看 题目大意:给出一个长度为 nnn 的字符串,假设共出现了 kkk 种字母,现在要求出一个长度为 kkk 的子序列,满足每种字母只出现一次,且字典序最大 题目分析:和之前牛客上的一道 ...
- Educational Codeforces Round 73 (Rated for Div. 2) E. Game With String 思维博弈 好题(2500)
传送门 文章目录 题意: 思路: 题意: 思路: 我们将每一段...拿出来看成若干段,将其分成以下四种情况: (1)len<b(1)len<b(1)len<b (2)b≤len< ...
- Educational Codeforces Round 40千名记
人生第二场codeforces.然而遇上了Education场这种东西 Educational Codeforces Round 40 下午先在家里睡了波觉,起来离开场还有10分钟. 但是突然想起来还 ...
- Codeforces 题目合集+分类+代码 【Updating...】【361 in total】
961A - Tetris 模拟 ...
最新文章
- 网络服务搭建、配置与管理大全(Windows版)
- Demon_接金币(三个掉落物品预设体,一接物体的工具)
- 1 搭建MyBatis环境
- js 中的[] {}是什么意思
- Google图片搜索的原理
- Node — 第九天 (ES6降级 and 发布属于自己的[第三方模块]包)
- python查看是否存在某个变量名
- 互亿无线python接口
- leo_物业收费管理系统
- 先码后看 Spring源码解析 侵立删
- android长度测量工具,手机测量长度软件
- sunshine in the rainsunshine in the rain
- D语言(dlang)编写单片机(cortex-m系列)应用需要用到的技巧
- bugku---啊哒
- 【面试】求最大最小的数
- comsol-超导线1
- 智能卡的操作系统——COS
- 我们可以容忍一个陌生人发迹,却不能容忍一个身边的人上升
- 用Windows电脑看小说,阅读器软件怎么选
- 计算机一级ms office考试模拟题,计算机一级MSOffice模拟试题及答案