题意:给你一个长度为n序列,如果这个任意连续子序列的中都有至少出现一次的元素,那么就称这个序列是不无聊的,判断这个序列是不是无聊的。先预处理出每个元素之前和之后相同元素出现的位置,就可以在O(1)的时间判断出一个元素在一个区间内是否唯一。每次从大的序列中找一个唯一元素,包含这个元素的就不用判断了,那...
分类:
其他好文 时间:
2015-08-01 20:30:30
阅读次数:
275
传送门十分重要的基础DP问题,是学习用各种方式优化DP的一个很好的例子。设DP[i]表示以a[i]结尾的LIS的长度,则状态转移方程为DP[1]=1DP[i] = max{DP[j], j1暴力求解复杂度为O(N^2)。优化1考虑函数f(L):长度为 L 的 Increasing Sequence ...
分类:
其他好文 时间:
2015-08-01 20:28:08
阅读次数:
90
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 127653 Accepted Submission(s): 31033
Problem Description
A number sequence is defined...
分类:
其他好文 时间:
2015-08-01 19:06:53
阅读次数:
99
题目:Given a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of themaximum positive product involving consecutive ...
分类:
其他好文 时间:
2015-08-01 15:39:01
阅读次数:
124
题目地址:http://poj.org/problem?id=1019Number SequenceTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 35680Accepted: 10287DescriptionA single pos...
分类:
其他好文 时间:
2015-08-01 11:29:15
阅读次数:
159
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5288解法:
定义两个数组L[i],R[i],表示第i数左侧和右侧最接近它且值是a[i]因子的数字的位置,那么第i个数能贡献的答案就是(R[i]-i)*(i-L[i]),因此每个数字x都去枚举它的因子y,然后左右找到一个值是y且最接近x的数,然后用他的位置更新一下L,R数组。时间复杂度O(nsqrt(a...
分类:
其他好文 时间:
2015-08-01 01:06:26
阅读次数:
105
题目链接:hdu 5297 Y sequence
考虑62以内的指数,x为奇数个质数因子,就减掉,偶数个加上。计算x为指数的不满足数直接pow(n,1/x)即可。
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
cons...
分类:
其他好文 时间:
2015-07-31 23:37:34
阅读次数:
127
# UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0x9d in position 1270: illegal multibyte sequence上面是遇到的错误,本来想完成读文件,再写入另一文件的。但是在 fp.read() 时,一直遇到上面的错误,经过各种百度,google, 还有神奇的 stackoverflow 才知道是字符流的问题。知...
分类:
编程语言 时间:
2015-07-31 16:27:47
阅读次数:
163
UTF-8是现在流行的编码方式,下面是RFC2279对UTF-8编码规则的规定
UCS-4 range (hex.) UTF-8 octet sequence (binary)
0000 0000-0000 007F 0xxxxxxx
0000 0080-0000 07FF 110xxxxx 10xxxxxx
0000 0800-0000 ...
分类:
其他好文 时间:
2015-07-31 16:23:54
阅读次数:
129
官方https://docs.python.org/3.4/library/string.html#string.Formatter6.1.string— Common string operationsSource code:Lib/string.pySee alsoText Sequence T...
分类:
其他好文 时间:
2015-07-31 14:40:16
阅读次数:
105