HDU 6103 Kirinriki (思维 双指针)】的更多相关文章

Kirinriki Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2169    Accepted Submission(s): 879 Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑i=0n−…
Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑(i=0  n−1)  |A[i]−B[n−1−i]|The difference between the two characters is defined as the difference in ASCII.You should find the maximum length of two non-ov…
http://acm.hdu.edu.cn/showproblem.php?pid=6103 题意: 给出一个字符串,在其中找两串互不重叠的子串,计算它们之间的dis值,要求dis值小于等于m,求能选的子串的最大长度. 思路: 由于这两个子串是互不重叠的,那么这两个子串之间的间隔可以是奇数也可以是偶数,针对这两种情况我们枚举中心点,然后尺取法处理,具体看代码就懂了. #include<iostream> #include<algorithm> #include<cstring…
题目链接:Kirinriki 题目描述: 找两个不重叠的字符串A,B. 使得dis(A,B)<=m;\(dis(A,B)= \sum _{i=0}^{n-1} \left | A_i-B_{n-1-i} \right |\).求最长的字符串长度. 思路: 官方题解,双指针维护.简单题.枚举对称中心. 在这里我给出我常用的双指针的写法. int a[N]; int l=0,r=0,val=0; while(r没有越界) //如果满足条件 { if(val+a[r]<=key) // 加上 a[r…
题目链接 Problem Description We define the distance of two strings A and B with same length n is disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of two non-over…
We define the distance of two strings A and B with same length n is dis A,B =∑ i=0 n−1 |A i −B n−1−i | disA,B=∑i=0n−1|Ai−Bn−1−i| The difference between the two characters is defined as the difference in ASCII. You should find the maximum length of tw…
Problem Description We define the distance of two strings A and B with same length n isdisA,B=∑i=0n−1|Ai−Bn−1−i|The difference between the two characters is defined as the difference in ASCII.You should find the maximum length of two non-overlapping…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5776 题目让你求是否有区间的和是m的倍数. 预处理前缀和,一旦有两个数模m的值相同,说明中间一部分连续子列可以组成m的倍数. //#pragma comment(linker, "/STACK:102400000, 102400000") #include <algorithm> #include <iostream> #include <cstdlib>…
http://acm.hdu.edu.cn/showproblem.php?pid=4803 话说C++还卡精度么?  G++  AC  C++ WA 我自己的贪心策略错了 -- 就是尽量下键,然后上键,最后下键补全,可是例子都过不了..... 题解參考http://www.cnblogs.com/xuesu/p/3967704.html http://www.cnblogs.com/Canon-CSU/p/3451784.html http://blog.csdn.net/keshuai199…
题目链接: B - Binary Tree  HDU - 5573 题目大意: 给定一颗二叉树,根结点权值为1,左孩子权值是父节点的两倍,右孩子是两倍+1: 给定 n 和 k,让你找一条从根结点走到第k层的路径,每经过一个结点,必须加上或者减去其权值,最后得到的结果是n: 具体思路:因为每个点都需要用到,所以我们先假设所有的点都需要用到,这个时候就全部是"+"号,然后通过二进制的性质,能够凑齐范围内的所有数,然后我们算一下差值还有多少,然后再减去这个差值就好了. AC代码: #incl…