10 2012 档案

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1541题被划在线段树里 刚开始想着是求区间k值 写着写着觉得错了 看着像求逆序数 写了个树状数组 怎么都过不了 无奈。。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define N 50000 7 struct node 8 { 9 int x,y,p;10 }s[N&l 阅读全文
posted @ 2012-10-22 18:49 _雨 阅读(187) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2795放在第几行 就是第几行的剩余空值x》xi 以行建树 求区间第K值View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define N 200010 7 #define LL __int64 8 LL s[N<<2],h,ww; 9 void build(int 阅读全文
posted @ 2012-10-21 22:03 _雨 阅读(186) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=3225先贴代码 有空再解释View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define N 140000 7 int s[N<<2],kc[N<<2],hash[N]; 8 void build(int l,int r,int w) 9 { 10 kc[w] = 0; 11 s[w] 阅读全文
posted @ 2012-10-21 22:00 _雨 阅读(196) 评论(0) 推荐(0) 编辑
摘要:A 判断不同字母的个数为偶数还是奇数#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){ int i,j,k,n,num[500]; memset(num,0,sizeof(num)); char str[201]; gets(str); k = strlen(str); for(i = 0 ; i < k ; i++) num[str[i]]++; int count = 0; for(i 阅读全文
posted @ 2012-10-21 21:58 _雨 阅读(314) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=3667之前网络赛水过一道区间合并的题 当时是全靠运气试对的 。昨天纠结了一晚上也没看出来哪错,改的都跟人家代码一样了还是不对,今天又重新敲了一遍,莫名的就对了,,开两个数组分别存这个区间两端点的连续区间 再开一标记数组 用来更新 向上向下都要更新View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 #define 阅读全文
posted @ 2012-10-18 13:35 _雨 阅读(217) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=1330这题只有一个询问,将一个节点的向上的标记下,再从另一个节点走一遍,遇到第一个被标记的就是 整个算法的最坏时间复杂度是O(Q*n),Q是询问的次数。View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 int father[10010],f[10010]; 6 int main() 7 { 8 int g,i,j,k,n,a,b,t,c,d; 9 cin>&g 阅读全文
posted @ 2012-10-11 17:41 _雨 阅读(175) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4135交了十几次,。最后发现理解错题意了,区间包含右端点,一直按不包含做的。。求出N的质因数 根据容斥原理解出区间数能被质因数整除的 再减掉View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstring> 5 using namespace std; 6 #define LL __int64 7 LL sum1,sum2,a,b,n; 8 int g, 阅读全文
posted @ 2012-10-11 08:36 _雨 阅读(202) 评论(0) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1796这篇文章对容斥原理讲解很清楚 http://www.cppblog.com/vici/archive/2011/09/05/155103.htmlView Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 LL sum,x[21],n; 8 i 阅读全文
posted @ 2012-10-10 17:23 _雨 阅读(212) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=1061这里解释的很详细。。http://blog.csdn.net/SwordHoly/article/details/4423543View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<string.h> 4 #include<cmath> 5 #define LL long long 6 using namespace std; 7 LL k,t,d; 8 LL exgcd(LL a,LL b) 9 {10 if(b== 阅读全文
posted @ 2012-10-09 15:09 _雨 阅读(211) 评论(0) 推荐(0) 编辑
摘要:中国剩余定理维基百科,自由的百科全书跳转到: 导航, 搜索中国剩余定理(Chinese Remainder Theorem,中国余数定理),古有“韩信点兵”、“孙子定理”、“鬼谷算”、“隔墙算”、“剪管术”、“秦王暗点兵”、“物不知数”之名,是数论中的一个重要命题。目录[隐藏]1 物不知数2 形式描述3 克罗内克符号4 近世交换环及推广5 参考书目[编辑] 物不知数在中国古代著名数学著作《孙子算经》中,有一道题目叫做“物不知数”,原文如下:有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二。问物几何?即,一个整数除以三余二,除以五余三,除以七余二,求这个整数。中国数学家秦九韶于1247年做 阅读全文
posted @ 2012-10-08 10:55 _雨 阅读(1172) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示