题目描述 你有一个字符串t,它由n个字母组成. 定义一个字符串s的子串为s[l...r],表示从位置l到r构成的一个新的串. 你的目标是构造一个字符串s,使得它的可能长度最小,要求s中存在k个位置i,可以找到k个以i为出发点的子串t. 输入: 第一行输入两个整数n和k,表示t的长度和需要k个子串第二行输入字符串t 输出: 输出满足条件的长度最小的s.题目保证答案唯一. kmp模板题,只要初始化一下,输出就完了. #include<iostream> #include<cstdio>…
题意:给定一个长度为n的串s,要求构造一个长度最小的使s出现了k次的串,可以重叠 n<=50,k<=50 思路:计算一下前后缀相同长度 #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<algorithm> #include<map> #include<set>…
http://codeforces.com/contest/1029/problem/A You are given a string tt consisting of nn lowercase Latin letters and an integer number kk. Let's define a substring of some string ss with indices from ll to rr as s[l…r]s[l…r]. Your task is to construct…
[题目链接]click here~~  [题目大意]:  You are given string s. Your task is to determine if the given string s contains two non-overlapping substrings "AB" and "BA" (the substrings can go in any order).  Input  The only line of input contains a…
题目如下: You are given two strings s and t of the same length. You want to change s to t. Changing the i-th character of s to i-th character of t costs |s[i] - t[i]| that is, the absolute difference between the ASCII values of the characters. You are al…
思路: 直接比较橘色框里的取第一次相等,即可. #include<iostream> #include<string> using namespace std; string x, y; int n, m, k; int main(){ cin>>n>>m; cin>>x; ;i<n;++i){ , n-i)){y=x.substr(n-i, n); k=; break;} } if(k){ cout<<x; ;i<m-;…
题目:https://pintia.cn/problem-sets/994805342720868352/problems/994805413520719872 题意: 给定两个数,表示成0.xxxxx*10^k次这样的科学记数法之后,判断小数点后的n位是否相同 思路: 分类大讨论.细节要考虑清楚.因为最多是100位所以要用字符串处理. 首先我们要知道这两个数的小数点在什么位置(digita,digtb),如果没有小数点就默认在最后一位. 然后我们还需要知道有没有前导零(firsta,first…
题目大意 题目看样例也能猜到就是输出最短的循环串. 吐槽 明明是div3第一题为啥子还会用到kmp的知识? 解法 这个题仔细看发现是求最长可去除的后缀,也就是说去除跟下一个相同的字符串还能连接起来.这个不就是next数组的功能吗?最长公共前后缀. 公式:len-next[len] 我们把前k-1个字符串只输出前面的部分最后加上一个完整的字符串即可 完整代码 #include <bits/stdc++.h> using namespace std; char a[500]; int nex[50…
作者: 负雪明烛 id: fuxuemingzhu 公众号:每日算法题 本文关键词:LeetCode,力扣,算法,算法题,字符串,并查集,刷题群 目录 题目描述 示例 解题思路 滑动窗口 代码 刷题心得 欢迎加入组织 日期 题目地址:https://leetcode-cn.com/problems/get-equal-substrings-within-budget/ 题目描述 给你两个长度相同的字符串, s 和 t . 将 s 中的第 i 个字符变到 t 中的第 i 个字符需要 |s[i] -…
[3]Longest Substring Without Repeating Characters [11]Container With Most Water [15]3Sum (2019年2月26日) 给了一个乱序的数组,返回一个结果数组,数组里面每个元素是一个三元组, 三元组的和加起来为0. 题解:先固定第一个数,然后后面两个数的控制用夹逼定理,2 pointers 来解. class Solution { public: vector<vector<int>> threeSu…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day in the IT lesson Anna and Maria learned about the lexicographic order. String x is lexicographically less than string y, if either x…
A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase English letters. Since Kerem likes it when things are different, he wants allsubstrings …
A character is unique in string S if it occurs exactly once in it. For example, in string S = "LETTER", the only unique characters are "L" and "R". Let's define UNIQ(S) as the number of unique characters in string S. For exam…
A character is unique in string S if it occurs exactly once in it. For example, in string S = "LETTER", the only unique characters are "L" and "R". Let's define UNIQ(S) as the number of unique characters in string S. For exam…
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/xie_0723/article/details/52790786 关于 Python Requests ,在使用中,总结了一些小技巧把,分享下. 1:保持请求之间的Cookies,我们可以这样做. import requests self.session = requests.Session() self.session.get(login_url) # 可以保持登录态 1 2 3 2:请求时,会…
B. String time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day in the IT lesson Anna and Maria learned about the lexicographic order. String x is lexicographically less than string y, i…
https://leetcode.com/problems/unique-letter-string/description/ A character is unique in string S if it occurs exactly once in it. For example, in string S = "LETTER", the only unique characters are "L" and "R". Let's define …
B. Different is Good 题目连接: http://www.codeforces.com/contest/672/problem/B Description A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recently got a string s consisting of lowercase E…
Codeforces Round #506 (Div. 3) 题目总链接:https://codeforces.com/contest/1029 A. Many Equal Substrings 题意: 给出长度为n的字符串,然后要求你添加一些字符,使得有k个这样的字符串. 题解: 直接暴力吧...一个指针从1开始,另一个从2开始,逐一比较看是否相同:如果不同,第一个指针继续回到1,第二个指针从3开始...就这么一直重复.最后如果第二个指针能够顺利到最后一位,那么记录当前的第一个指针,把他后面的…
关于 Python Requests ,在使用中,总结了一些小技巧把,分享下. 1:保持请求之间的Cookies,我们可以这样做. import requests self.session = requests.Session() self.session.get(login_url) # 可以保持登录态11 2:请求时,会加上headers,一般我们会写成这样 self.session.get(url, params, headers=headers) 唯一不便的是之后的代码每次都需要这么写,…
B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem recen…
题目链接: B. Different is Good time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different. Kerem…
->点击<- A. Summer Camp time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Every year, hundreds of people come to summer camps, they learn new algorithms and solve hard problems. This is your f…
CF比赛题解(简单题) 简单题是指自己在比赛期间做出来了 A. Many Equal Substrings 题意 给个字符串t,构造一个字符串s,使得s中t出现k次;s的长度最短 如t="cat",k=3, minlen(s)=9,s=catcatcat 1<=len(t),k<=50 题解 稍加思考是个前缀等于后缀的问题,用kmp的next数组模板 假设t[0..l-1]==t[n-l....n-1] 那么应该不断重复t[l...n-1]这样的子串 代码如下(应该好好记住…
题目如下: A character is unique in string S if it occurs exactly once in it. For example, in string S = "LETTER", the only unique characters are "L" and "R". Let's define UNIQ(S) as the number of unique characters in string S. Fo…
题面 该场 Div. 3 最"难"的一道题:Funny Substrings O I D \tt OID OID 队长喜欢玩字符串,因为 " O n e I n D a r k " \tt "OneInDark" "OneInDark" 是一个望而生畏的字符串. O I D \tt OID OID 会进行 N \tt N N 次操作,每次操作形如以下两种之一: x := S : x 是变量名称,S 是一个具体的字符串,:= 符…
题意: 输入一个正整数N(<=100),接着输入两个浮点数(可能包含前导零,对于PAT已经习惯以string输入了,这点未知),在保留N位有效数字的同时判断两个数是否相等,并以科学计数法输出. trick: 测试点3含有有效数字在小数点以后的数据,此时指数应该是小数点位置减有效数字位置再加上1. AAAAAccepted code: #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; stri…
A. Anton and Danik time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Anton likes to play chess, and so does his friend Danik. Once they have played n games in a row. For each game it's known…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
A. Alyona and copybooks time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have eq…