CSU 1554 SG Value —— 思维】的更多相关文章

题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (multiset) is the minimum positive integer that could not be constituted of the number in this set. You will be start with an empty set, now there are two…
http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 这题在比赛的时候居然没想出来,然后发现居然是做过的题目的变种!!!! 先不考虑插入操作,就给定一堆数字,求出不能组成的最小的那个正数. 思路是,排序,然后维护一个区间[L, R]表示当前能组合成的数字.比如1.2就能组合成[1, 3]的所有数字. 那么下一个数a_i,我们需要其不能大于R + 1,否则会断,R + 1就是不能组合成的最小数字,比如a_i = 5就GG. 那么这题增加了插…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=1554 Description The SG value of a set (multiset) is the minimum positive integer that could not be constituted of the number in this set.You will be start with an empty set, now there are two o…
SG Value Problem's Link:   http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1554 Mean: 一个可重集合,初始为空,每次插入一个值,询问这个集合的SG值(集合中的数字组合相加不能达到的最小值)是多少. analyse: 这题方法很巧妙. 假设当前不能达到的最小值为v,对于要插入的一个新值x 1)如果x>v,那么v的值不会改变,我们用一个优先队列(从小到大)将x进队; 2)如果x<=v,那么v的值会改变为v+x,然…
题目大意: 2种操作 1 a:往集合中添加一个元素a 2: 询问这个集合中的元素任意组合相加所不能得到的最小数的值 这道题总是不断地去找当前所能处的最小值能否被当前的最小值加上其前部的一堆可抵达数到达当前位置 也就是 minn < *s.begin() , 说明此时内部最小的元素是不影响这个值的,否则 minn+=*s.begin(),然后剔除最小值,不断往下访问 在这里因为相同数据也可以同时保存在集合内,所以不采用set(会删除重复元素),而是使用multiset. 在这里顺便学习理解一下mu…
1554: SG Value Submit Page    Summary    Time Limit: 5 Sec     Memory Limit: 256 Mb     Submitted: 497     Solved: 167 Description The SG value of a set (multiset) is the minimum positive integer that could not be constituted of the number in this se…
1554: SG Value Time Limit: 5 Sec  Memory Limit: 256 MBSubmit: 140  Solved: 35 Description The SG value of a set (multiset) is the minimum positive integer that could not be constituted of the number in this set.You will be start with an empty set, no…
1547: Rectangle Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Submitted: 1198     Solved: 347 Description Now ,there are some rectangles. The area of these rectangles is 1* x or 2 * x ,and now you need find a big enough rec…
题目为中文,因而不再解释题意. 首先遵循如下设定可以有以下几个结论:1,首先谈论下KMP的一个特殊性质:对于某一个特立独行的字符串:例如ABCDEF,在建立有限状态自动机之后,都会有,所有元素的失配边,指向0,也就是初始的那个元素.此时我们可以讲这个独立的元素及之前字符串理解为“ 一个循环次数为1的循环串 ”.对于其他情况,形如:ABCDEFGAB,可以将ABCDEFG理解为一个循环串,AB为下一个循环的两个多余元素,因此,我们可以把任意字符串看成“ 一个循环串+若干独立元素 ”的巧妙形式. 2…
预处理last[i]表示以第i个开始,的合法后缀. pre[i]表示以第i个结尾,的合法前缀. 那么每一个数a[i],肯定是一个合法后缀last[i] + 一个合法前缀,那么合法前缀的数字要小于a[i],并且最大,bit维护小于等于val的最大值即可. #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #inc…