题目传送门 1 /* 2 贪心/二分查找:首先对ai%=p,然后sort,这样的话就有序能使用二分查找。贪心的思想是每次找到一个aj使得和为p-1(如果有的话) 3 当然有可能两个数和超过p,那么an的值最优,每次还要和an比较 4 注意:不能选取两个...
分类:
其他好文 时间:
2015-06-08 11:33:39
阅读次数:
117
http://acm.hdu.edu.cn/showproblem.php?pid=5265#include
#include
#include
using namespace std;
const int maxn=100000+5;
int data[maxn];
int main()
{
int m,p;
whil...
分类:
其他好文 时间:
2015-06-08 09:50:39
阅读次数:
94
题意:设有两个串A和B,现将B反转,再用插入的形式合成一个串。如:A:abc B:efg;反转B先,变gfe;作插入,agbfce。现在给出一个串,要求还原出A和B。思路:扫一遍O(n),串A在扫的时候直接输出,串2在扫的时候反向存储,再输出。 1 #include 2 #include 3 ...
分类:
其他好文 时间:
2015-06-08 01:01:34
阅读次数:
135
题意:给一个序列,找出两个数字a和b(可以相等但不可相同),要求(a+b)%p的结果最大。思路:先将所有元素模p,再排序。要找出a和b,分两种情况,a+b>p和a+b 2 #include 3 #include 4 #include 5 #include 6 #include 7 #def...
分类:
其他好文 时间:
2015-06-08 00:53:18
阅读次数:
137
//n个黑球,m个白球,第i个数为白球si = 0,为黑球si = 1;
//求这个串s中出现01的期望
//期望是可以加的
//那么对于第i个位置出现0第i+1出现1的概率为(n/(n+m))*(m/(n+m-1))
//那么期望为n*m/(n+m-1)
#include
#include
#include
using namespace std ;
int gcd(int a...
分类:
其他好文 时间:
2015-06-04 21:08:15
阅读次数:
139
1563. Bayan
Time limit: 1.0 second
Memory limit: 64 MB
As everybody knows, there are a lot of stores in skyscrapers, it's the favourite place of glamorous girls. Blonde Cindy loves only one...
分类:
其他好文 时间:
2015-06-01 13:18:28
阅读次数:
171
题目链接:CF Round #444 div1 C题目分析这道题目是要实现区间赋值的操作,同时还要根据区间中原先的值修改区间上的属性权值。如果直接使用普通的线段树区间赋值的方法,当一个节点表示的区间完全被要求修改的区间包含时,就直接打上赋值的标记然后 return 。但是这样这个节点中每个位置原先的...
分类:
其他好文 时间:
2015-05-26 20:44:45
阅读次数:
245
DescriptionUser ainta loves to play with cards. He has a cards containing letter "o" and b cards containing letter "x". He arranges the cards in a row...
分类:
其他好文 时间:
2015-05-21 17:01:16
阅读次数:
133
Tales of seafaringMemory limit: 128 MBYoung Bytensson loves to hang out in the port tavern, where he often listens to the sea dogs telling their tales...
分类:
其他好文 时间:
2015-05-21 10:27:09
阅读次数:
251
hdu 5229 ZCC loves strings
题意:
CC有N个字符串,他正在和Miss G.用这N个字符串玩一个小游戏。ZCC会从这N个串中等概率随机选两个字符串(不可以是同一个)。然后,ZCC和Miss G.轮流操作。Miss G.总是先操作的。在每轮中,操作者可以选择操作A或操作B。
操作A:在两个串中选择一个当前非空的串,然后在这个串的末尾删去一个字符。
操作B: 若当前两...
分类:
其他好文 时间:
2015-05-18 13:03:22
阅读次数:
151