自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

suikay的专栏

Knowledge will lock your imagination

  • 博客(88)
  • 收藏
  • 关注

原创 Eureka! (续)

克里希那穆提曾明确地把快乐和快感明确区分开来。他认为快乐是一种不功利的愉悦, 而快感更多的是欲望的满足。ACM曾经把两样都带给我了。把那些比赛胜利后的喜悦和刷题 的快感刨去后,剩下的是思考的快乐。我想可以把这些快乐两种,分别是,理解算法的快乐 和应用算法的快乐。    虽然觉得算法艰难的人比觉得算法优美的人多。但是不可否认,每个学过算法人都会有 那种"what the fuck!"的时刻。原来

2012-09-11 01:00:05 553

原创 Eureka!

写这篇文章的冲动,缘起于昨天晚上的小事。昨天晚上快要休息的时候,在亚马逊上瞎逛,发现了一本好书《网络、群体与市场》(亚马逊的推荐系统真给力)。一看目录和简介就知道,这应该是一本关于将数学模型应用到实际使用中的例子的书。而且内容似乎蛮丰富的。价钱也公道,500+页只需要40+RMB。控制不住自己的购书欲望,一下子就下了单,就差付款了。幸运的是,支付宝在chrome上使用需要安装插件。等插件安装完

2012-09-05 01:02:07 691 2

原创 POJ 1095

这道题感觉上只是一道简单的推理题,它的难点应该是把生成树的规律找出来吧。首先,我们要得到一个节点数为x的二叉树有几种,这里用arr[x]表示。据说有一个叫做卡特兰的公式可以确定这个数组。但实际上只要通过观察即可发现,通过枚举左右子树的数量可以得到arr[x]:for (int i = 0; i 其次,如果一棵树的序号为X,如何确定其节点数:由于题目已经说明:All binary trees having m nodes have numbers less than all those having m+1

2011-03-24 12:00:00 1596 1

原创 POJ 3625 Building Roads 解题报告

 题意:给出N个坐标点的位置,其中的K个是已经相连的,求把它们连在一起需要最短的路径和。分析:典型的最小生成树。一开始我选择了Kruskal(我也不知道怎么会选上的。。)。把所有有可能的边全部添加进去,外加stl的heap优化。#include #include #include #include #include #include #include #incl

2009-08-04 15:36:00 1008 1

原创 1011 Sticks

 摘自Poj的warmtrue大牛:1。降序排列,从最长的开始一个个找。如果找的是第一根杆而且最长的没有选到则终止。2。两个相同值,前一个搜索失败后后一个也不用找了。这两条都是搜索经常用到的剪枝,不过我写的时候忽略了第二条,TLE。加了以后32MS就过了。#include #include #include using namespace std;int n,ori_s

2009-07-31 16:55:00 502

原创 POJ 1149 PIGS 解题报告

 可以将每个顾客能打开的猪圈合并为一个,如果其中一个已经被合并过,则加一条由此猪圈 到 之前拥有这个猪圈钥匙的顾客的猪圈,容量为无穷。这样我们就可以得到一个带s,t,和 N个中间节点的流量图。然后求最大流即可。#include #include #include using namespace std;const int M(1100),N(110),INF(0x7ffffff

2009-07-29 12:25:00 642

原创 最长子序列的更优解法

这个算法巧妙之处在于利用了大部分之前的计算的信息。这里开了一个数组,记录最长子序列stack,stack[n]记录长度为n的子序列的最小序列尾数。 举例:原序列为1,5,8,3,6,7  读完8以后,栈为1,5,8,此时读到3,则用3替换5,得到栈中元素为1,3,8,  再读6,用6替换8,得到1,3,6,再读7,得到最终栈为1,3,6,7, 最长递增子序列为长度4。(例子来自于h

2009-07-21 16:50:00 520

原创 POJ 3414 Pots

本来用string来记录状态,tle,于是改为用类似于并查集的方法记录。只记录 此次动作 和 上一个动作的位置。中间又有一些低级失误,wa了n次。。orz/*ID: immozer1PROG: ****LANG: C++*/#include #include #include #include #include #include #include

2009-07-15 01:55:00 650

原创 linux 下 java 的path问题

今天打算在linux下写个helloworld。敲完代码,javac,米问题。java jw.class 结果如下:root@slax:~# java hw.classException in thread "main" java.lang.NoClassDefFoundError: hw/classCaused by: java.lang.ClassNotFoundException:

2009-04-19 10:34:00 692

原创 2954 Triangle 解题报告

/*Pick公式:整点多边形的面积=内部整点个数+边上的整点个数/2 - 1.*/#include#include#includeusing namespace std;int _tmp;void swap(int &x,int &y){ _tmp = x; x = y; y = _tmp;}int gcd(int x,int y){

2009-04-18 17:20:00 379

原创 1151 Atlantis 解题报告

 让人很崩溃的一题,我觉得自己用错方法了,居然写了3000+B的代码,写完都ft了...虽说比波哥的快了32ms,但是他的只有2500-B的代码啊,加上他爱开空行的习惯真不懂我比他多写了多少,ft again. 出乎意料的顺利地几乎1y ,出了个pe,ft once more下面是代码#include#include#include#includeusing namespa

2009-04-07 15:38:00 430

原创 3277 City Horizon 解题报告

 线段树离散化的第二题,做起来困难重重,wa到快崩溃了。偷看了一下波哥的博客才把它做出来了。活生生的一个山寨。。。今天要把线段树的题目刷完~//这次线段树用的是半开区间,跟以往有些不同//错误主要集中于线段树的insert操作,另外在//map用1为起始下标导致了2+的wa//ERRORS: 5 wa + 3 tle + 1 re#include#include#in

2009-04-07 12:18:00 582

原创 2528 Mayor's posters 解题报告

  很久米做线段树的题了,昨天看了一下江离的解题报告。发现一个好东西--离散化,这题里面贴海报的范围很广0~10000000,尝试了几次原始的线段树都mle了。现在的代码可以很轻松的就把它给ac了,这就是离散化的伟大之处... #include#include#includeusing namespace std;#define NIL 10000001#defin

2009-04-06 16:37:00 573

原创 POJ 3504 Obfuscation 解题报告

//这道题的解法有点傻...首先对字符串进行hash//得到其在字典中的位置,然后比较两个hash值(hash2,hash3)//是否相等,另外用dp[i]表示其位置是否能达到,0为不能//-1为多种可能,否则就用 101*到达i位置的字符串对应的hash+字符串长度#include#include#include#define P1 3543#define P2

2009-04-04 16:16:00 1579

原创 POJ 1971 Parallelogram Counting 解题报告

 #include#include#include#define MAX 1000#define HMAX 0x3fffff#define P 0x1fffff//将每个中点的x,y都记录下来,如果//同时记录拥有这个中点的线段的个数struct Point{ int x; int y; int count; int next;};Poin

2009-03-30 16:53:00 1151

原创 POJ 1200 Crazy Search 解题报告

 #include#include#include#includeusing namespace std;#define MAX 5000000#define P 3313//用静态链表代替动态链表struct Hash{ int hash; int next;};Hash h[MAX];int c[MAX];char x[MAX];in

2009-03-30 14:57:00 1906

原创 POJ 3349 Snowflake Snow Snowflakes

 #include#include#include#define P1 3313#define P2 3329#define MAX 10000000//这里用静态数组代替了动态数组//时间减少了一半struct Hash{ int h2; int next;};//使用h1[i]记录和为i雪花对应的hash值的位置int h1[MAX];H

2009-03-29 11:23:00 1432 6

原创 福州oj 1689 未ac

/* 这题应该不难,主要是将种族杀掉不同怪物 数分别做成一个背包,另外是记录杀死n个怪物 * 所需要的能量,但是为什么就ac不了呢。。 */#include#include#includeusing namespace std;int m,n,p;//e[i][j] 用于记录第i个种族杀掉j个怪物所需要的最少能量//用d[i][j]记录前i个种族要杀掉j个怪

2009-03-22 13:40:00 1166

原创 2661 Factstone Benchmark 解题报告

#include#include#define pi 3.14159265#define e 2.71828183 int main(){ int y,last(0); double m; for(int y = 1; y <= 22; y++){ m = pow(2.0,y)/log(2.0); for(int n = 1; true; n

2009-03-15 11:22:00 488

原创 1363 Rails 解题报告

#include#includeusing namespace std;int main(){ bool v[5010],flag1,flag2; int n,tmp; while(cin>>n&&n) { while(cin >> tmp&& tmp) { bool res(true); memset(v,f

2009-03-10 17:14:00 496

原创 zoj 1610 count the color

#include#include#includeusing namespace std;#define NoCol 8009#define MulCol -2#define M 8010struct TNode{ int left,right; int col;};TNode t[10*M];void Construct(int pos,

2009-03-09 11:25:00 594

原创 2777 Count Color 解题报告

 #include#include#define L 100010#define C 35#define NoCol 0#define MulCol -1struct TNode{ int left,right; int col;};TNode tree[L*10];bool col[35];//创建线段树void const

2009-03-07 11:39:00 371

原创 2346 Lucky tickets 解题报告

Memory: 2612K Time: 63MSLanguage: G++Fault: 0  #include#include//将数分为左右两边,然后用选择原则把一个数出现的情况平方//即左边出现的情况乘以右边同时出现这个数的情况即可int poss[6][100020];int main(){ int N; scanf("%d",&N);

2009-03-05 23:18:00 404

原创 2236

Memory: 396K Time: 0MSLanguage: G+Fault: 2 wa #define M 1440#include#include#includeusing namespace std;int n,m,t;//这里用动态规划算出最早的开始时间用ttime来记录//arrive用来记录车到达的时间int ttime[M],arr

2009-03-05 22:37:00 500

原创 2239 Nearest number - 2 解题报告

Memory: 1040KTime: 360MSLanguage: G++Faults: 0Algorithm: dp搜索 #include#include#define MP 40005#define abs(x) (x>0)?x:(-x)//分别用于记录0点的坐标和当前距离最短的点的值int zx[MP],zy[MP],dis[MP],ze[MP];//用于记录

2009-03-05 21:39:00 440

原创 2231 Moo Volume 解题报告

Memory: 472KTime: 32MSLanguage: G++Faults: 7 waAlgorithm: dp 这道题最让人郁闷的是输入方式 %I64d  -> 我用了 %lld 结果wa了 #include#include#includeusing namespace std;long long cows[10001];int main(){

2009-03-04 20:49:00 401

原创 2184 Cow Exhibition 解题报告

Memory:  1228KTime: 47MSLanguage: G++Faults: 3 TLE + 2WA  + 1 REAlgorithm: dp  #includeusing namespace std;#define MID 100050bool in[200100];// 用dp[i]记录smartness为i的情况下funness的最大值// 由于s

2009-03-04 19:52:00 312

原创 2181 Jumping Cows 解题报告

Memory:  304KTime: 94MSLanguage: G++Faults: 0Algorithm: dp/* 这应该也算是dp吧 记录上次odd time的取值 和 even time 的取值 */#includeint main(){ int p,tmp,_neg, pos(0),neg(0); scanf("%d",&p); for(in

2009-03-04 11:37:00 368

原创 2081 Recaman's Sequence 水题报告

 #include#includeusing namespace std;bool in[10000000];int d[500010];int main(){ int tmp = d[0] = 0; for(int i = 1; i <= 500000; i ++) { if(tmp > i && !in[tmp-i]) tmp -= i;

2009-03-04 10:54:00 314

原创 2063 Investment 解题报告

 Memory: 612KTime: 16 MSLanguage: G++Faults:2 wa + ...Algorithm: dp /* 由“The value of a bond is always a multiple of $1 000”可以推知 可以把所有的value除以1000来简化dp “The interest of a bond is never more

2009-03-04 10:40:00 807

原创 2679 Adventurous Driving 解题报告

 Memory: 324KTime: 0MSLanguage: G++Faults:20 wa + ...Algorithm:最短路径 #include #include #include #include using namespace std;#define N 1110#define M 10010#define INFINITY 9999999//分

2009-03-04 10:00:00 526

原创 2983 Is the Information Reliable? 解题报告

Memory: 2776KTime: 860MSLanguage: G++Faults:5 wa+1 oleAlgorithm:查分约束/* 这题我是用差分约束做的 求的是最短路,如果有负环 则 inreliable*/#include #include #include using namespace std;#define NIL 100000000#d

2009-03-04 09:55:00 312

原创 2385 Apple Catching 解题报告

 简单的dp,本来ac的人少,以为很难.尝试着交了结果1y =>Memory: 1004K Time: 32MSLanguage: G++ Faults:0#include//用max[i][j]储存在i树下,转移了j次情况下能得到的最多苹果数int max[2][31];int main(){ int T,W;

2009-02-25 07:52:00 534

原创 1742 Coins 解题报告

传说中“男人八题”中最简单的一道,但是在没有看别人的解题报告前我还是没能解出来。。后来终于过了。其实我ac的算法也是一个普通的dp,只是状态记录和以前的有些不一样而已。使用了一个use[x]来记录达到x使用当前第i个硬币的个数.Memory: 1368K Time: 2282MSLanguage: G++ Faults:5 tle#include#include#inclu

2009-02-12 10:53:00 365

原创 1690 (Your)((Term)((Project))) 解题报告

发现自己近来都被水题卡住,而且还很喜欢为它们写报告。。。没办法,谁叫自己菜呢。。。Memory: 284K Time: 0MSLanguage: G++ Faults:8 was#include#include#includechar s[2600];bool get[2600];int time,p;ch

2009-02-11 18:12:00 422

原创 1644 To Bet or Not To Bet 解题报告

本来不想给这么水电题目写报告了的,但是自己居然在这上边wa了8次,把一些该留意到细节写下来。有时候都不知道该不该对double进行精度判断了。。。平时要注意初始化   #include#include#include#define M 55#define T 44#define NIL 999999int is[M],m,t;double dp[M][M];

2009-02-11 12:42:00 533

原创 1609 Tiling Up Blocks 解题报告

 这道题考察dp的基础,开始没注意l1==l2&&m12 的情况wa了一次Memory: 324K Time: 0MSLanguage: G++ Faults:1 waAlgorithm:DP /* *我的做法是从底至上 */#include#include#define N 102int lm[N][N];bool input(){ i

2009-02-11 00:19:00 451

原创 1456 Supermarket 解题报告

  很水的一道题,但是居然wa了两次。下次要注意了:以bool为返回值的函数不一定默认返回true #include#include#include#define N 10110using namespace std;typedef struct Product{ int w; int dl; bool operator()(Product a,Product

2009-02-10 23:26:00 353

原创 1083 Moving Tables

 这道题太水了,但是自己还是错了.平时要注意看题,因为1,2号房间占用同一段门廊.wa了一次.其余的只要注桌子意可能从后到前搬,输入处理一下即可.然后直接贪心

2009-02-07 15:40:00 354

原创 1160 Post Office 解题报告

 Memory: 1292KTime: 16MSLanguage: G++Fault:(none) 一道dp水题,状态不好,居做了这么久... #include #include #define V 315#define P 32int dp[V][P];int p[V];int d[V][V];int main(){ int v,p

2009-02-07 14:45:00 414

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除