- 博客(6)
- 收藏
- 关注
转载 斐波那契博弈 hdu 2516
引用:点击打开链接有一堆个数为n(n>=2)的石子,游戏双方轮流取石子,规则如下:1)先手不能在第一次把所有的石子取完,至少取1颗;2)之后每次可以取的石子数至少为1,至多为对手刚取的石子数的2倍。约定取走最后一个石子的人为赢家,求必败态。结论:当n为Fibonacci数的时候,必败。f[i]:1,2,3,5,8,13,21,34,55,89……用第二数学归纳法证明:为了方便,我们将n记为f...
2018-02-26 23:10:23
191
原创 二维树状数组
链接:https://www.nowcoder.com/acm/contest/77/E来源:牛客网情人节的电灯泡时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言65536K#include<bits/stdc++.h> using namespace std; int C[1010][1010],mp[1010][1010],n,m,tmp; in...
2018-02-25 19:51:38
211
原创 树状数组求逆序对数
#include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> using namespace std; #define ll long long const int maxn=100000; ll a[maxn+10]...
2018-02-25 19:40:58
365
原创 线段树区间修改入门
#include<bits/stdc++.h> using namespace std; const int maxn=1e5+10; int tree[4*maxn],lazy[4*maxn],a[maxn]; void update(int p){ tree[p]=tree[p<<1]+tree[p<<1|1]; } void pushdown(int p...
2018-02-25 19:38:27
490
转载 c++ stirng insert
string的成员函数insert有以下多种重载:string &insert(int p0, const char *s);——在p0位置插入字符串sstring &insert(int p0, const char *s, int n);——在p0位置插入字符串s的前n个字符string &insert(int p0,const string &s);——在p0...
2018-02-08 19:58:10
201
原创 hdu3068 hihocoder 1032 最长回文子串 马拉车算法
#include<bits/stdc++.h> using namespace std; const int maxn=1e6+10; char s1[maxn],s2[2*maxn];int p[2*maxn]; void gets2() { int len=strlen(s1); s2[0]='%'; for(int i=1;i<2*len;i+=2) { s2[...
2018-02-08 18:34:04
209
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人