上一页 1 2 3 4 5 6 7 ··· 18 下一页
题意:n对数,大小为1、2、3、...、n。现要求两个1之间有1个数,两个2之间有2个数,以此类推,两个n之间有n个数,并且,数的次序可以随意的。解法:我们用sum()表示求和运算。1.设k(k=1,2,..,n)放置的第一个位置为ak,第二个位置为bk。显然有bk-ak=k+1(ak<bk)那么会有sum(bk-ak)=2+3+4+...+(n+1)=(1+2+3+...+n)+(1+1+...+1)=n*(n+3)/2。2.又因为要有2*n个位置来放置这2*n个数。则sum(ak+bk)=1+2+3+...+2*n=(1+2*n)*(2*n)/2=(1+2*n)*n。3.sum(ak Read More
posted @ 2012-12-03 20:39 To be an ACMan Views(812) Comments(0) Diggs(0)
View Code #include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#include<vector>using namespace std;const int maxn = 100100;vector < pair<int, int> > v;vector <int> a, b, c;#define ALL(c) c.begin(), c.end()int main(){ int i, j; for(i = Read More
posted @ 2012-12-01 20:40 To be an ACMan Views(138) Comments(0) Diggs(0)
这次比赛题目明显较长,自己没耐心读题,心还是太急了。给自己总结了几个缺点:1.心太急,总想侥幸过掉。2.本能觉得有些题目很简单,考虑不充分,没想好思路就敲。3.草稿纸要书写规范,以免重复计算。4.题目长就耐心读题,没什么好抱怨的。5.独立思考能力还不够,总想依赖别人。日后做题要尽量避免这些情况。C题严重考虑错误。View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){ int i, j; double y1, y2, yw, Read More
posted @ 2012-11-26 11:59 To be an ACMan Views(222) Comments(0) Diggs(0)
View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define maxn 50003#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1int col[maxn<<2];int lsum[maxn<<2], msum[maxn<<2], rsum[maxn&l Read More
posted @ 2012-11-24 19:43 To be an ACMan Views(160) Comments(0) Diggs(0)
View Code #include<stdio.h>#include<string.h>#include<algorithm>#include<vector>using namespace std;const int maxn = 8000<<1;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1int n;int col[maxn<<2];int vis[maxn< Read More
posted @ 2012-11-24 18:15 To be an ACMan Views(189) Comments(0) Diggs(0)
View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;const int maxn = 65666<<1;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r) >> 1int col[maxn<<2], XOR[maxn<<2];bool vis[maxn<< Read More
posted @ 2012-11-24 15:06 To be an ACMan Views(184) Comments(0) Diggs(0)
注意离散化View Code #include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define lson l, m, rt<<1#define rson m+1, r, rt<<1|1#define mid int m = (l + r)>>1#define maxn 10004int col[maxn<<4];int l[maxn], r[maxn];int a[maxn<<4], m, n;int Read More
posted @ 2012-11-24 12:52 To be an ACMan Views(205) Comments(0) Diggs(0)
方法一:先暴力求出每个字串是否是回文(枚举每个回文串的中间字符),保存在dp[i][j]中再从以求的小区间滚成大区间View Code #include<stdio.h>#include<string.h>char s[5005];int dp[5005][5005];int main(){ int i, j, k, x, y; int len = strlen(gets(s+1)); for(i = 1; i <= len; i++) // 枚举每个回文串的中间字符 { for(j = k = i; j >= 1 && k <= le Read More
posted @ 2012-11-22 20:56 To be an ACMan Views(773) Comments(0) Diggs(0)
出处:http://blog.csdn.net/lalor/article/details/7358956poj3461Oulipo最简单的KMP题,找出第一个字符串在第二个字符串中出现次数。View Codepoj2752SeektheName,SeektheFame求子串前缀跟后缀一样的各种情况View Codepoj2406PowerStrings求子串在主串中最多叠加次数View Codepoj1961Period跟上面一题几乎一样,把主串的每一种前缀当作小主串,如果小主串的子串在小主串中叠加次数大于1,输出小主串长度及叠加次数。View Code #include<stdio. Read More
posted @ 2012-11-20 23:11 To be an ACMan Views(496) Comments(0) Diggs(0)
注意:重复的只算一次如何去掉一些重复的是本题的关键我的去重思路:75 3 7 6 3 2 165 3 7 3 155 3 2 1 3第一组在推到 数字 2 的时候有 3会出现重复, 显然前面一个3是可有可无的。第二组也一样,前面一个3是可有可无的。1.如果最长下降序列中有后面一个3, 如第一二组数据,那么前面一个3是无用的,在推好后面一个3之后把之前的所用重复的计数数组清零2.如果最长下降序列中只有前面一个3,如第三组数据, 做情况1的操作也是不会影响结果的,因为第三组的前面一个3的状态已经推到2后才被清零的。View Code #include<stdio.h>#include& Read More
posted @ 2012-11-15 22:02 To be an ACMan Views(400) Comments(0) Diggs(0)
上一页 1 2 3 4 5 6 7 ··· 18 下一页