上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 99 下一页

2012年7月30日

Expression 栈 + 搜索

摘要: ExpressionTime Limit : 6000/2000ms (Java/Other)Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 10Accepted Submission(s) : 7Font:Times New Roman|Verdana|GeorgiaFont Size:←→Problem DescriptionYou shoule remove valid pairs of parentheses from a valid arithmetic expression,and you will get 阅读全文

posted @ 2012-07-30 22:43 more think, more gains 阅读(189) 评论(0) 推荐(0) 编辑

Binary Operation

摘要: 题意:a1⊙a2⊙a3= a1⊙a2+ a1⊙a3+ a2⊙a3a1⊙a2⊙a3⊙a4= a1⊙a2+ a1⊙a3+ a1⊙a4+ a2⊙a3+ a2⊙a4+ a3⊙a4算法:1.朴素算法O(n ^2),肯定不行,百万级别数据2.考虑二进制性质,统计所有位1的个数,由异或可知,0,1为1分别统计每位的和。比如第1位sum += (N - bit[1]) * bit[1] * (1<<i)View Code #include<stdio.h>#include<string.h>#include<stdlib.h>int d[40];int main 阅读全文

posted @ 2012-07-30 16:48 more think, more gains 阅读(211) 评论(0) 推荐(0) 编辑

Pattern and Text

摘要: 又是一道优化时间复杂度的算法。朴素O(N * N) ( N <= 2000000)可以优化成O(N)的时间复杂度View Code #include<stdio.h>#include<stdlib.h>#include<string.h>#include<iostream>using namespace std;char word[2001000], str[2000100];int num[2001000];int main( ){ int N; scanf("%d",&N); while( N-- ) { s 阅读全文

posted @ 2012-07-30 16:41 more think, more gains 阅读(176) 评论(0) 推荐(0) 编辑

Square Submatrix

摘要: 题意:给你个N*N矩阵,(N《=400),找出其子矩阵中左对角线和(左上角到右下角),减右对角线和(左下角到右上角)最大差值。算法:普素算法是 O( N * N * N * N )超时,关键是优化求对角线和算法。以空间换时间。用两个二维数组保存好对角线和。O( N * N * N ) acView Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>using namespace std;int mp1[410][410];int mp2[410 阅读全文

posted @ 2012-07-30 16:34 more think, more gains 阅读(230) 评论(0) 推荐(0) 编辑

非诚勿扰 贪心

摘要: 贪心策略: 分成两组求解: 男生要求女生比它工资低时。。。 用高工资男生把 先把高工资的女生匹配掉 男生要求女生比他高时。。 用女生高工资匹配高工资男生的。View Code #include<stdio.h>#include<string.h>#include<stdlib.h>#include<algorithm>#include<vector>using namespace std;vector<int>girl[2];vector<int>boy[2];int M = 0;/* 贪心策略: 男生要求女生 阅读全文

posted @ 2012-07-30 16:29 more think, more gains 阅读(156) 评论(0) 推荐(0) 编辑

上一页 1 ··· 12 13 14 15 16 17 18 19 20 ··· 99 下一页

导航