上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 30 下一页
摘要: 1521. War Games 2Time Limit: 1.0 secondMemory Limit: 16 MBBackgroundDuring the latest war games (this story is fully described in the problem"War games") the Minister of Defense of the Soviet Federation comrade Ivanov had a good chance to make sure personally, that an alertness of the Sovi 阅读全文
posted @ 2012-08-28 12:27 yejinru 阅读(448) 评论(0) 推荐(0) 编辑
摘要: /*题目: 给出n个铜件,每个铜件拥有银和金的含量si,gi,然后问最终把这些铜件融在一起后 银的含量为m,然后问金的含量大概有多少分析: 将金银映射为坐标,将银的含量表示为x轴的坐标,然后金的含量表示为y轴,然后求 凸包,接着做垂直于x轴的直线,交凸包于两点,那两点即为所求,若没有的话,直接 输出0 注意: 1.点都在凸包上的直线 2.点在凸包上的点 3.点不在凸包上的范围内 4.求出的两点大小相反*/#include <iostream>#include <cstdio>#include <cstring>#include <cm... 阅读全文
posted @ 2012-08-10 09:30 yejinru 阅读(170) 评论(0) 推荐(0) 编辑
摘要: /*题目: XML有缩进,并且会在之前的缩进基础上缩进几个空格,现在问缩进k个空格的标签分析: 模拟队列,及时更新空格即可*/#include <iostream>#include <cstdio>#include <cstring>#include <vector>using namespace std;const int X = 20005;int n,k;char s[105];char p[105];vector<int> vec[X];struct node{ char s[105]; int num;}q[X],ans[X 阅读全文
posted @ 2012-07-25 12:48 yejinru 阅读(201) 评论(0) 推荐(0) 编辑
摘要: /*题目: 模拟排队的实现,但是若是有同伙的话,这些家伙就会插队,排到他们的同伙的后面,要不就乖乖地排到队伍的后面。现在给出朋友关系以及进队出队的顺序,问你当出队时是谁在出队分析: 利用优先队列,重载小于号,使得优先级最大的先出队,优先级的定义如下:当前面有同伙时,按照前面的同伙的优先级来插入,若没有的话,就按照现在的优先插入。当优先级相同时,按照先进队的优先级越大就越大。*/#include <iostream>#include <cstdio>#include <queue>#include <cstring>using namespace 阅读全文
posted @ 2012-07-25 12:47 yejinru 阅读(232) 评论(0) 推荐(0) 编辑
摘要: /*题目: 每一天都只能每一种鱼,并且买了这种鱼后,在以后每周的该天都得买那种鱼。 另外如果某一天没买鱼的话,就不能在以后买鱼了(已被饿死。。。)。现在 给出n天每一种鱼的价格,并且给出你拥有的价钱,问你什么时候不能再买鱼了分析: map[i,j]表示从第一天开始买了j种鱼到i天时所用的总价钱。然后从后面开始枚举 答案,枚举一周内每天所使用的价钱总和若不大于你拥有的金钱时就输出答案*/#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int X = 阅读全文
posted @ 2012-07-25 12:46 yejinru 阅读(164) 评论(0) 推荐(0) 编辑
摘要: /*用结构体数组模拟栈,结构体中保存当前min与max的值*/#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int X = 65537;int n,top;struct node{ int max,min;}stack[X];int main(){ freopen("sum.in","r",stdin); char s[10]; int x; int ncase = 0; while(cin>> 阅读全文
posted @ 2012-07-25 12:44 yejinru 阅读(202) 评论(0) 推荐(0) 编辑
摘要: /*题目: 模拟输出数字时钟分析: 先把答案都只为空格,然后枚举每一个数字,在相应的答案数组上做修改,这样的话,只需 做出来了数字8,其他的都可以实现了。代码很简练,只有100来行*/#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int X = 205;char map[X][X],s[X];int n;int main(){ freopen("sum.in","r",stdin); freopen(&qu 阅读全文
posted @ 2012-07-25 12:42 yejinru 阅读(187) 评论(0) 推荐(0) 编辑
摘要: /*题目: 给出n个矩形的坐标,求所有的矩形的覆盖面积分析: 离散化,具体请看Matrix67 http://www.matrix67.com/blog/archives/108*/#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int X = 205;double x[X],y[X];int topx,topy;int n;double lx[X],rx[X],ly[X],ry[X];bool 阅读全文
posted @ 2012-07-22 11:44 yejinru 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 次小生成树:在求最小生成树时,用数组path[i][j]来表示MST中i到j最大边权。求完后,直接枚举所有不在MST中的边,把它加入到MST中构成一棵新的树,且该树有环,此环是由刚加入的边(I,j)造成的,所以可以通过删除path[i][j]即可得到新的一颗树,且所有的该类树中必有一棵为次小生成树。比如如图所示:G,H不是MST上的边,通过加入边(G,H),得到一个环(B,H,G),然后由于在计算最小生成树时已经计算出G,H之间最大边权为path[G][H] = BH,所以通过删除BH即可得到一棵此时最小的生成树,然后更新答案即可#include <iostream>#includ 阅读全文
posted @ 2012-06-18 22:04 yejinru 阅读(716) 评论(0) 推荐(0) 编辑
摘要: /*题目: 给出n,问n = b^p中p符合该等式的最大值分析: 先求出所有n的质因子,然后对这m个质因子分类统计,比如 n = 36时,可以分成 2个2,2个3,然后求出所有这些基数的 最大公因数gcd。另外由于有负数的存在,所以求到的gcd若 为偶数时,需要不断除二直到为奇数为止*/#include <iostream>#include <cstdio>#include <cstring>#include <cmath>using namespace std;const int X = 150000;int di[50],top;int pr 阅读全文
posted @ 2012-06-15 21:28 yejinru 阅读(304) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 30 下一页