IT民工
加油!
05 2012 档案
COJ 1030 素数槽
摘要:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1030用线性筛素数果然快多了。#include<cstdio>#include<cstring>#include<cstdlib>#define MAXN 1300000bool is_p[MAXN];void calc(){ for( int i = 1; i < MAXN; i ++) is_p[i] = true; is_p[1] = false; for( int i = 2; i < MAXN; i ++) { if( !is_p[i.. 阅读全文
posted @ 2012-05-26 22:35 找回失去的 阅读(533) 评论(1) 推荐(0)
POJ 3278 Catch That Cow
摘要:一维的广搜,从当前点到下个点有三种选择,然后求步数即可。用了STL的队列,然后忘了加using namespace std,检查浪费了时间。/*Accepted 860K 110MS C++ 640B 2012-05-26 20:44:59 */#include<cstdio>#include<cstring>#include<cstdlib>#include<queue>using namespace std;#define MAXN 100005int d[MAXN], N, K;void bfs(){ queue<int> q; 阅读全文
posted @ 2012-05-26 20:51 找回失去的 阅读(184) 评论(0) 推荐(0)
POJ 2488 A Knight's Journey
摘要:http://poj.org/problem?id=2488 好久没写回溯,题目要求骑士遍历全图,不能实现就输出“impossible”,首先遍历的方向要选好,字典序,其次判断遍历了全图的条件就是走了p*q-1步。初始点选取A1即可。/*Accepted 168K 16MS C++ 1267B 2012-07-23 15:35:53*/#include<cstdio>#include<cstring>#include<cstdlib>const int MAXN = 30;const int dx[] = {-2, -2, -1, -1, 1, 1, 2, 阅读全文
posted @ 2012-05-26 20:23 找回失去的 阅读(175) 评论(0) 推荐(0)
POJ 2785 4 Values whose Sum is 0
摘要:用hash写了一遍,hash的空间复杂度不是盖的/*Accepted 176460K 3907MS C++ 1006B 2012-05-25 09:13:41 */#include<cstdio>#include<cstring>#include<cstdlib>#define cal(x) ( (x + (1 << 29 | 1) * M) % MAX)#define LL __int64const int MAX = 20000001;const int M = 17531753;const int MAXN = 4005;int hash[ 阅读全文
posted @ 2012-05-25 09:15 找回失去的 阅读(210) 评论(0) 推荐(0)
HDU 2037 今年暑假不AC
摘要:今年暑假不AC,这是道很不错的贪心题,至于怎么贪呢,我们尽量选择结束时间靠前的节目,这样就可以保证在一定时间内能看到更多的题目。/*2012-05-07 12:29:59 Accepted 2037 0MS 268K 621 B C++ */#include<cstdio>#include<cstring>#include<cstdlib>const int MAXN = 105;typedef struct{ int s, e;}T;T Ti[MAXN];int cmp( const void *_p, const void *_q){ T *p = ( 阅读全文
posted @ 2012-05-07 12:38 找回失去的 阅读(1988) 评论(0) 推荐(1)
POJ 2785 4 Values whose Sum is 0
摘要:枚举左边两个数的和以及右边两个数的和,用二分查找将其配对并计数。Hash的方法晚点再写。/*Accepted 49208K 5188MS C++ 1146B 2012-05-04 23:56:30 */#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>using namespace std;#define MAXN 4005/*int cmp( const void *_p, const void *_q){ int *p = ( int *)_p; int 阅读全文
posted @ 2012-05-05 00:00 找回失去的 阅读(341) 评论(0) 推荐(0)
POJ 1316 Self Numbers
摘要:按照题目的要求我们将有generator的数标记,然后输出没标记的即可。/*Accepted 168K 16MS C++ 412B 2012-05-04 22:50:01 */#include<cstdio>#include<cstring>#include<cstdlib>bool is[10005];int main(){ int i, j, res, sum; memset( is, false, sizeof is); for( i = 1; i <= 10000; i ++) { if( !is[i]) { p... 阅读全文
posted @ 2012-05-04 22:58 找回失去的 阅读(171) 评论(0) 推荐(0)
POJ 1046 Color Me Less
摘要:先输入16个像素点,然后每输入一个像素点,输出与其最相近的像素点。/* Accepted 176K 0MS C++ 664B 2012-05-04 22:34:22 */#include<cstdio>#include<cstring>#include<cstdlib>#include<cmath>#define MAXN 20int A[MAXN], B[MAXN], C[MAXN];int a, b, c;int k;int main(){ for( int i = 0; i < 16; i ++) scanf( "%d%d% 阅读全文
posted @ 2012-05-04 22:43 找回失去的 阅读(196) 评论(0) 推荐(0)