09 2012 档案

摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=78原来Graham都是模板直接上的,这次是自己写的,发现自己尽是细节没搞好View Code 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 const int maxn = 105; 5 struct Point 6 { 7 float x,y; 8 }p[maxn],stack[maxn]; 9 10 double xmult(Point p1,Point p2,Point p 阅读全文
posted @ 2012-09-29 22:55 YORU 阅读(237) 评论(0) 推荐(0)
摘要:今天照着自己的理解写了Graham.自己写错了很多次,所以先前看到的可能错了。。View Code 1 const int maxn = 105; 2 struct Point 3 { 4 float x,y; 5 }p[maxn],stack[maxn]; 6 7 double xmult(Point p1,Point p2,Point p0) //cross product 8 { 9 return (p1.x-p0.x)*(p2.y-p0.y)-(p1.y-p0.y)*(p2.x-p0.x);10 }11 12 double dis(Point p1,... 阅读全文
posted @ 2012-09-29 21:06 YORU 阅读(168) 评论(0) 推荐(0)
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3654首先必须说自己今天很2。。。。。一个数据范围搞了那么久,还有就是自己对表达式的理解上也有问题。。。。View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 2012 4 long long ans; 5 char str[maxn]; 6 7 void cal(char str[]) 8 { 9 int i,j,len,f,mark;10 long long te 阅读全文
posted @ 2012-09-29 19:56 YORU 阅读(293) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1113求凸包....完全上模板的,先过了,然后自己在仔细看看Graham算法View Code 1 #include <stdio.h> 2 #include <iostream> 3 #include <math.h> 4 #include <algorithm> 5 using namespace std; 6 const int maxn =1005; 7 const float pi = 3.14159265; 8 struct Point 9 {10 float x,y;11 }p[ 阅读全文
posted @ 2012-09-27 22:53 YORU 阅读(359) 评论(0) 推荐(0)
摘要:凸多边形--整个图形在任一条边的一侧凸图形--任意两个内点在任一内分点也在内部凸包--对于一个平面点集或者一个多边形,它的凸包指的是包含它的最小凸图形或最小凸区域凸包的求法 --从最左边的最低点P0开始 --找到一个点P1,使得P0为起点的水平方向的射线到P0P1的角度最小 --然后找下一个P2,使得P2P1到P1P0角度最小。 --。。。。。。 --则P0P1P2....Pm是凸包上的顶点 --实际比较的时候,不一定要用角度来衡量 --可以采用叉乘来判断:只要知道相对的方向(顺时针还是逆时针)就可以 --比如判断AC1和AC2的夹角大小,只要判断AC1在AC2的右边 -... 阅读全文
posted @ 2012-09-27 18:40 YORU 阅读(700) 评论(0) 推荐(0)
摘要:点与多边形的的位置关系--点在形内 --点在形外--点在边界上判断方法--射线法--转角法射线法--通常取X轴正方向为射线方向--奇数次相交,则在形内--偶数次相交,则在形外对于凹多边形也是可以的射线法的特殊情况--与定点相交 --与其相邻的端点或者线段在射线的异侧,则认为是相交 --否则不认为相交与边部分重合--缩点法:遇到一个在射线上的点,向后梁旭跳过所有也在射线上的点,直到第一个不再射线上的点,在用上述条件。--平移法:将射线稍微上升或下降很小的一个量。 --实际操作时不用真的平移,只需要判断较高的端点高于射线,较低的端点低于射线或恰在射线上... 阅读全文
posted @ 2012-09-27 13:08 YORU 阅读(1828) 评论(0) 推荐(1)
摘要:非规范相交的集中情况--它们没有被判定为相交是因为它们在叉乘过程中,都至少有一次叉乘为0.--但是叉乘为0并不一定就是非规范相交。因为叉乘结果为0表示是某个点在某向量所在的直线上。如下情况也可能使叉积结果为0,尽管它们并不是规范相交或者规范相交。非规范相交的判定的思路--某个端点P在另外一条线段P1P2所在直线上--且该端点P在线段P1P2上 --即min(P1.x, P2.x) ≤P.x ≤max(P1.x, P2.x)且min(p1.y,p2.y)≤P.y ≤max(p1.y,p2.y)判断顶点在线段上的另外一种方法--可以用点乘判断顶点在线段上的另外一种方法--假设已经知道点P在P1P. 阅读全文
posted @ 2012-09-26 09:33 YORU 阅读(458) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4417这题刚开始的时候没想到,xianbin5说是先标记,再是离线查询。因为他的查询操作和对改动数据的操作是分开的,也就是说可以把查询操作重新排序,按照自己的顺序来查询。那么就可以想按照数据从大到小的顺序查询,当然事先是先把原来的数组存起来进行比较。。。就这样。。。(*´∀`*)View Code 1 #include <iostream> 2 #include <algorithm> 3 #include <string.h> 4 #include <st 阅读全文
posted @ 2012-09-25 23:54 YORU 阅读(344) 评论(0) 推荐(0)
摘要:摘自 《计算几何》 --谢迪规范相交---两条线段恰有唯一一个不是断点的公共点。可以用解析几何解法1.列直线方程: Ax+By+C=0 判断解的情况 --若无解则平行 --无穷多解,则说明共线 --唯一解 -判断是否分别在两条线段的内部解析结合解法的问题 1.求解方程需要浮点除法运算 --浮点误差 特别是接近平行时 --浮点除法运算速度2.总体效率 --需要比较定点 --交点没有用计算几何的算法 --仅需要加、减、乘 --不求交点如何判断?两条线段相交时,每条线段两个端点都在另一条线段的异侧两条线段相交时,每条线段的端点都在另一条线段的异侧--判断异侧--有... 阅读全文
posted @ 2012-09-25 20:44 YORU 阅读(1388) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1247字典树的题目,以前自己没想到怎么做就一直都放在那里了。今天突然看到,然后想了下,自己有了思路然后就写了下。虽然WA了几次,但总算是让我过了。。。~~o(>_<)o ~~View Code 1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 using namespace std; 5 const int maxn = 50005; 6 string str[maxn],s[m 阅读全文
posted @ 2012-09-25 07:05 YORU 阅读(267) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3496这题是一道二维费用背包问题,刚开始的时候我把所有的都初始化为-1,只有ans[0][0]=0;结果就是一直在WA,我没想明白是怎么回事,我认为要满足只有恰好用完的话,那只要将所有的都设置为-1就可以了。后来看了别人的题解,我是略2,想的是没错。如果要恰好用完的话,是要将别的都初始化为-1。但是这个恰好是指的物品的件数恰好,那么就是说二维的费用中有一个费用是恰好,所以初始化-1的时候只要是对有这个要求的这一维进行初始化就可以了。想到了先前做树状数组也是,总是有点生搬硬套o(╯□╰)o。。。看到别人的代码说 阅读全文
posted @ 2012-09-23 10:32 YORU 阅读(356) 评论(0) 推荐(0)
摘要:文哥突然问我这两题有什么不同。我真的不知道怎么说。POJ 2155 是更新的数据的一段,但是求的是某个点的数据。POJ 1195 是更新的数据的一点,但是求的是数的点。可以想象为一维的树状数组,其实POJ 2155的话,就好比是在数组 a 上[n...m]的值都加上K的更新。而POJ 1195的话就好像是在数组 a 上某个点的值遭到改变,然后求区间[n...m]的值。POJ 1195 像是 NYOJ 116 士兵杀敌(二)POJ 2155 像是 NYOJ 123 士兵杀敌(四) 阅读全文
posted @ 2012-09-22 21:33 YORU 阅读(161) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2155二维的树状数组,这题要逆向。即最开始的点的是树状数组的终点。。。View Code 1 #include <iostream> 2 #include <string> 3 using namespace std; 4 const int maxn = 1005; 5 int ans[maxn][maxn],n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 void mod(int x,int y,int c)12 {13 int i;14 wh 阅读全文
posted @ 2012-09-22 21:02 YORU 阅读(188) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2660做下这道二维费用的问题。。。。。结果自己把两个维数代表的东西都搞反了,最重要的是TM的样例过了。。。然后自己就泪奔。。。。最后看别人题解,和自己是一样的啊。。。然后就仔细看了下代码,过了。内循环其实是可以互换循环的位置的。不知道为什么AC 1 #include <iostream> 2 using namespace std; 3 const int weight_maxn = 1005; 4 const int number_maxn = 25; 5 int ans[weight_maxn 阅读全文
posted @ 2012-09-22 19:48 YORU 阅读(303) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2299看到题目想到的就是归并排序....然后文哥告诉我是树状数组,等下再去看看树状数组怎么写,会可以求出逆序对。View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn = 500005; 4 long ans[maxn],fark[maxn]; 5 long long temp; 6 void merge(int p,int q,int r) 7 { 8 int i,j,l; 9 i=p;10 j=q+1;11 l=p;... 阅读全文
posted @ 2012-09-21 20:49 YORU 阅读(166) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4339二分查找,这里的二分查找有点特别,因为low虽然在边,但是作为比较的左值是不变的。View Code 1 #include <stdio.h> 2 #include <iostream> 3 #include <string.h> 4 using namespace std; 5 const int maxn = 1000005; 6 int ans[maxn]; 7 char str1[maxn],str2[maxn]; 8 int lowbit(int x) 9 阅读全文
posted @ 2012-09-21 19:16 YORU 阅读(128) 评论(0) 推荐(0)
摘要:http://baike.baidu.com/view/157384.htm?subLemmaId=157384&fromenter=%D6%D0%B9%FA%CA%A3%D3%E0%B6%A8%C0%EDhttp://zh.wikipedia.org/wiki/%E4%B8%AD%E5%9B%BD%E5%89%A9%E4%BD%99%E5%AE%9A%E7%90%86 注释:三数为a b c,余数分别为 m1 m2 m3,%为求余计算,&&是“且”运算 1、分别找出能被两个数整除,而满足被第三个整除余一的最小的数。 k1%b==k1%c==0 && k 阅读全文
posted @ 2012-09-21 10:36 YORU 阅读(319) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1195早上起来A题,结果隔壁寝室的不知道在争论什么,声音真是大。。。。让人都静不下心来。。View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1050; 5 int ans[maxn][maxn]; 6 7 int lowbit(int x) 8 { 9 return x & (-x);10 }11 12 void mod(int temp[], int x, int c) 阅读全文
posted @ 2012-09-21 09:01 YORU 阅读(140) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=3刚开始的时候自己没想到,然后看大牛的题解。一直不懂的是为什么大牛用两个点就可以求出面积来。问了明智,知道了原来是因为所有的面积的计算表达式的展开会消去相同的项,然后就两个点表示就可以了。大牛的日志:http://blog.csdn.net/niushuai666/article/details/7454078View Code 1 #include <stdio.h> 2 #include <math.h> 3 #include <iostream> 4 #i 阅读全文
posted @ 2012-09-17 10:59 YORU 阅读(719) 评论(0) 推荐(0)
摘要:http://codeforces.com/problemset/problem/224/B暴力View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=100005; 4 bool f[maxn]; 5 int ans[maxn],s[maxn]; 6 int main() 7 { 8 int n,k,i,j,mark; 9 cin>>n>>k;10 {11 mark=-1;12 for(i=0;i<n;i++)13 {14 ... 阅读全文
posted @ 2012-09-17 09:54 YORU 阅读(193) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=63数据结构。View Code 1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int n,m,i,j; 6 while(cin>>n>>m,n||m) 7 { 8 j=1; 9 for(i=0;i<n;i++)10 {11 if(m%2)12 {13 j=j*2;... 阅读全文
posted @ 2012-09-17 09:03 YORU 阅读(146) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2352刚开始想对二维的是怎么更新的, 后来才知道原来Y轴是递增.也就是对同一个点来说, 每次Y增加的都是这个这个点现在的层数的下一层.然后想, 如果它在当前点的X又点了一下,按照题意,相当于在同一点点了连续点了两下.其实每次更新一层...Y表示层数View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=60000; 4 int ans[maxn]; 5 int stars[maxn]; 6 int lowbit(int x) 7 { 8 re 阅读全文
posted @ 2012-09-15 20:57 YORU 阅读(269) 评论(0) 推荐(0)
摘要:View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define m 10 4 #define M 20 5 int gcd(int a, int b) 6 { 7 return !b?a:gcd(b,a%b); 8 } 9 int main()10 {11 char s1[m],s[M],s2[M],c;12 int a,b,k,i,len,t=0;13 while(~scanf("%s%s%ld%s%s",s,s1,&b,s2,s2))14 {15 t++;16 ... 阅读全文
posted @ 2012-09-15 15:57 YORU 阅读(154) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=45刚开始没注意,是大数....View Code 1 #include <stdio.h> 2 #include <string.h> 3 int ans[102][61]; 4 int main() 5 { 6 int i,j,n,t,k; 7 memset(ans,0,sizeof(ans)); 8 ans[1][0]=4; 9 for(i=2;i<102;i++)10 {11 k=0;12 for(j=0;j<61;... 阅读全文
posted @ 2012-09-14 16:23 YORU 阅读(214) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=90今天开始上算法课了,这是今天老师将的书本上的递归的内容。View Code 1 #include <iostream> 2 using namespace std; 3 int f(int n,int m) 4 { 5 if(n<1 || m<1) return 0; 6 if(n==1 || m==1) return 1; 7 if(n == m) return f(n,n-1)+1; 8 if(m > n) return f(n,n); 9 ret... 阅读全文
posted @ 2012-09-12 21:10 YORU 阅读(209) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4350取余。举例子 3 31 2 3 4 5 1 2 3 4 5 1 2 3 4 5.1 2 3 4 5 1 2 3 4 5 1 2 3 4 5.由图可以看出,取的恰好是N个(L-R+1)的长度,然后就可以取余可以求得现在相对于R位置的位置。View Code 1 #include <stdio.h> 2 #define maxn 52 3 int ans[maxn]; 4 int main() 5 { 6 long t,n,l,r,d=0,i,j,mark; 7 scanf("%ld& 阅读全文
posted @ 2012-09-11 21:12 YORU 阅读(200) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4287MAP 无压力.View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <map> 4 #include <string.h> 5 using namespace std; 6 int main() 7 { 8 int t,n,m,i,j,num; 9 long ans[5005],sum,k;10 char str[7];11 int character[26]={2,2,2,3,3, 阅读全文
posted @ 2012-09-10 19:45 YORU 阅读(173) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=4278进制转换,以前看过一道十进制转换为十三进制的,现在忘记哪里做过了0 1 2 3 4 5 6 7 8 9 十进制0 1 2 3 4 5 6 7 八进制View Code 1 #include <stdio.h> 2 #include <string.h> 3 int main() 4 { 5 long a[10]={0,1,2,0,3,4,5,6,0,7},i,j,sum,k; 6 char s[100]; 7 while(~scanf("%s",&s) 阅读全文
posted @ 2012-09-10 19:16 YORU 阅读(118) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=100暴力也可以,但是应该和谐..http://www.cnblogs.com/graphics/archive/2010/06/21/1752421.html在这里看到了别的做法View Code 1 #include <stdio.h> 2 int main() 3 { 4 int n,num,t; 5 scanf("%d",&t); 6 while(t--) 7 { 8 scanf("%d",&n); 9 num=0;10 阅读全文
posted @ 2012-09-07 18:03 YORU 阅读(156) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1257找数列中递减数列的个数....View Code 1 #include <iostream> 2 #include <cstdio> 3 using namespace std; 4 const int maxn=1000005; 5 int ans[maxn],num; 6 bool f[maxn]; 7 int main() 8 { 9 int n,i,t,j;10 while(~scanf("%d",&n)){11 for(i=0;i<n; 阅读全文
posted @ 2012-09-06 21:19 YORU 阅读(158) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2689这题冒泡能过,反正我是归并的....题目就是求逆序对..View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=101; 4 int ans[maxn][maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int n,m,k,s,i,j,l,max; 8 while(cin>>n>>m>>k>>s) 9 {10 max=-1; 阅读全文
posted @ 2012-09-06 20:39 YORU 阅读(163) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2159二维的背包问题....个人感觉是0/1背包和完全背包的结合.View Code 1 #include <iostream> 2 using namespace std; 3 const int maxn=101; 4 int ans[maxn][maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int n,m,k,s,i,j,l,max; 8 while(cin>>n>>m>>k>>s) 9 {10 max=- 阅读全文
posted @ 2012-09-06 19:58 YORU 阅读(167) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=267好烦....View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char stack[maxn],str[maxn],source[maxn],aim[maxn][10]; 5 double num[maxn],s[maxn]; 6 int main() 7 { 8 int i,j,l,k,t,le,rear,f=0,mark,iter; 9 double a... 阅读全文
posted @ 2012-09-05 21:19 YORU 阅读(190) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=257栈的应用....View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char stack[maxn],str[maxn],source[maxn]; 5 int main() 6 { 7 int i,j,l,k,t,le,rear; 8 scanf("%d",&t); 9 while(t--)10 {11 scanf("%s" 阅读全文
posted @ 2012-09-05 20:10 YORU 阅读(184) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=228本想用树状数组的, 结果有点囧...........然后看了别的大牛的做法.... 离线查询的可以有o(n)的算法...View Code 1 2 #include <iostream> 3 #include <stdio.h> 4 using namespace std; 5 const int maxn = 1000005; 6 const int M = 10003; 7 int ans[maxn]; 8 int main() 9 {10 int n, m, q 阅读全文
posted @ 2012-09-05 12:17 YORU 阅读(205) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=123这题本来交上去就超时了, 然后自己就囧了.... 不知道该用什么更高级的结构了...然后去百度的题解....看到的是和我一样的思路, 但怎么就过了呢.. 仔细看了下, 别人的更新都是从当前点更新到0位置.然而我是从当前点, 更新到数组的结尾, 结果就不行了.然后自己改了下代码就过了......感觉是数据出的问题,偏向了某一边把....用线段树是不是会更好呢?View Code 1 #include <iostream> 2 #include <stdio.h> 3 # 阅读全文
posted @ 2012-09-04 22:24 YORU 阅读(248) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=116和 士兵杀敌(一) 是一样的。View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 f 阅读全文
posted @ 2012-09-04 21:34 YORU 阅读(132) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=108线段树,或者树状数组View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 for(i 阅读全文
posted @ 2012-09-04 21:14 YORU 阅读(146) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=36今天突然想到那天文哥给我看的最长公共子序列的问题....然后自己找了这道题来看看..那天文哥叫我看的时候, 自己就这么一下扫过去. 没什么概念.今天自己从头按照它的分析方法来分析了下.f[i][j] 表示 s1 的 i 个字符和 s2 的 j 个字符内最长的公共子序列if(s1[i] == s2[j]) f[i][j] = f[i-1][j-1] + 1;else f[i][j] = max(f[i-1][j], f[i][j-1]); 当不相同的时候,则考虑在 s1 的 i 个字符和 s.. 阅读全文
posted @ 2012-09-04 16:03 YORU 阅读(366) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1058话说这题是动态规划的吧. 刚开始就想到的是直接暴力, 用一个有序数列.数列的最开头的数字是最小的,然后将它乘以2,3,5,7后得到的数字放回数列中,同时将第一个数字出列....然后只要出了5842个数字就刚好了.set 容器刚好满足 1.去重, 2.排序 View Code 1 #include <stdio.h> 2 #include <iostream> 3 #include <set> 4 using namespace std; 5 const int max 阅读全文
posted @ 2012-09-03 21:07 YORU 阅读(178) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=44水题一道. 很早的时候就知道怎么做了,但是以前都是只知道是怎么做的. 但是自己没有去分析过...第 i 位的时候,如果求的值要最大则是ans[i]=max(ans[i-1]+a[i], a[i]);View Code 1 #include <stdio.h> 2 #define maxn 1000005 3 int ans[maxn], a[maxn]; 4 int max(int a, int b) 5 { 6 return a > b ? a : b; 7 } 8 int 阅读全文
posted @ 2012-09-03 20:02 YORU 阅读(237) 评论(0) 推荐(0)
摘要:http://blog.csdn.net/niushuai666/article/details/7400587看过神牛的RMQ算法之后自己算是默写了遍.....交上去的时候,华丽丽的超时了。因为我用的是 cin cout才想到当输入和输出的次数多时,那么这两个是很耗时间的。View Code 1 2 #include <iostream> 3 #include <stdio.h> 4 #include <cmath> 5 using namespace std; 6 const int maxn= 100010; 7 int maxsum[maxn][20 阅读全文
posted @ 2012-09-03 17:02 YORU 阅读(213) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3183思路:如果没有别的可能的话,只能是最后的N位。但是前面的可能有比N位中的首位更小的数字m,然后找到这个更小的。再从m开始到最后N-1位找N-1位数字的首数字。View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 1005 4 char s[maxn]; 5 int ans[maxn]; 6 int main() 7 { 8 int i, l, n, len, d, end, mark; 9 char 阅读全文
posted @ 2012-09-03 11:40 YORU 阅读(234) 评论(0) 推荐(0)
摘要:http://blog.csdn.net/niushuai666/article/details/6624672通过学习这位神牛的文章初步认识 RMQ....View Code 1 #include <iostream> 2 #include <cmath> 3 #define maxn 10005 4 using namespace std; 5 int maxsum[maxn][20], minsum[maxn][20]; 6 7 void RMQ(int num) //预处理->O(nlogn) 8 { 9 int i, j;10 for(j = 1; j 阅读全文
posted @ 2012-09-03 10:19 YORU 阅读(649) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=104看了下别人的解题报告, 才知道原来还是相当于一维的数组的最大子序列的问题....只是将二维的数组转换为一维的数组继续求最大子序列View Code 1 #include <stdio.h> 2 #define maxn 101 3 int ans[maxn], temp[maxn][maxn]; 4 int row(int n, int ans[]) 5 { 6 int i, b=0, sum=-1000000; 7 for(i=0; i<n; i++) 8 { 9... 阅读全文
posted @ 2012-09-02 15:29 YORU 阅读(349) 评论(0) 推荐(0)
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=311View Code 1 #include <stdio.h> 2 #define maxn 50005 3 #define INF -1 4 int ans[maxn],v[maxn],w[maxn]; 5 int main() 6 { 7 int t, n, m, i, j; 8 scanf("%d",&t); 9 while(t--)10 {11 scanf("%d%d",&n,&m);12 for(i=0; i 阅读全文
posted @ 2012-09-02 11:17 YORU 阅读(134) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1176数塔问题的变形.....(算不上变形吧..View Code 1 #include <stdio.h> 2 #include <string.h> 3 #define maxn 100005 4 int ans[maxn][13], dp[maxn][13]; 5 int max(int a, int b, int c) 6 { 7 return (a > b ? a : b) > c ? (a > b ? a : b) : c; 8 } 9 int main( 阅读全文
posted @ 2012-09-01 16:21 YORU 阅读(139) 评论(0) 推荐(0)