IT民工
加油!
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 29 下一页
摘要: 被虐得很惨的一道题,WA了无数次,根据题意推出C*x+(2^k)*y=B-A,用拓展欧几里德求出x的最小值。如果无解则是死循环!/*Accepted 164K 0MS C++ 882B 2012-07-19 12:03:12*/#include<cstdio>#include<cstring>#include<cstdlib>#define LL long longLL extgcd( LL a, LL b, LL &x, LL &y){ if( b == 0) { x = 1; y = 0; return a;} LL d = extgcd 阅读全文
posted @ 2012-07-19 12:10 找回失去的 阅读(195) 评论(0) 推荐(0) 编辑
摘要: 线段树,维护每个区间的maxy,查找时用二分。/*Accepted 3627 1203MS 6848K 2698 B C++*/#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MAXN = 200010;struct TPoint{ int x, y, flag;}pre[MAXN], ans[MAXN], s;char op[10];int n, m;struct Segtree{ int l, r, maxy;}tree[MAXN < 阅读全文
posted @ 2012-07-15 16:45 找回失去的 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 要仔细看题,不然PE和各种莫名其妙的WA就来了!今天开始继续写博客!http://acm.hdu.edu.cn/showproblem.php?pid=3625/*Accepted 3625 0MS 248K 818B C++ Yu */#include<cstdio>#include<cstring>#define LL __int64LL dp[21][21];LL sum;double ans[21][21], p[21][21];void init(){ memset( dp, 0, sizeof dp); memset( ans, 0, sizeof ans) 阅读全文
posted @ 2012-07-14 22:27 找回失去的 阅读(344) 评论(2) 推荐(0) 编辑
摘要: 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 找回失去的 阅读(520) 评论(1) 推荐(0) 编辑
摘要: 一维的广搜,从当前点到下个点有三种选择,然后求步数即可。用了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 找回失去的 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 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 找回失去的 阅读(156) 评论(0) 推荐(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 找回失去的 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 今年暑假不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 找回失去的 阅读(1972) 评论(0) 推荐(1) 编辑
摘要: 枚举左边两个数的和以及右边两个数的和,用二分查找将其配对并计数。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 找回失去的 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 按照题目的要求我们将有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 找回失去的 阅读(162) 评论(0) 推荐(0) 编辑
上一页 1 ··· 9 10 11 12 13 14 15 16 17 ··· 29 下一页