- 博客(10)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 Sicily目录
1024: http://blog.csdn.net/wbchou/article/details/85652891028: http://blog.csdn.net/wbchou/article/details/85861971029: http://blog.csdn.net/wbchou/article/details/85916791063: http://blog.csdn.
2013-02-18 19:33:55
441
原创 Sicily 1172 Queens, Knights and Pawns
没什么好说的,把代码写简洁一些。#include #include using namespace std;enum Status {OCCUPIED, UNSAFE, SAFE};typedef pair Loc;Loc queensForward(Loc& loc, int type) { switch (type) { case 0: --loc.first;
2013-02-21 17:05:18
389
原创 Sicily 1206 Stacking Cylinders
由下面两个圆圆心的坐标求上面那个圆的坐标,如图,由(x1, y1)(x2, y2)求(x3, y3)别被输入示例骗了,有乱序的情况。#include #include #include #include using namespace std;int main() { int cases; cin>>cases; int counter=0; while
2013-02-20 21:28:54
510
原创 Sicily 1381 a*b
高精度乘法#include #include using namespace std;string add(string a, string b) { if (a.length()<b.length()) a.swap(b); int carry=0; string::reverse_iterator aIter=a.rbegin(); string::reverse
2013-02-19 17:46:18
270
原创 Sicily 1029 Rabbits
f(n)=f(n-1)+f(n-m)高精度加法#include #include #include using namespace std;string add(string a, string b) { // Assumption: a>b int carry=0; string::reverse_iterator aIter=a.rbegin(); strin
2013-02-19 16:28:32
472
原创 Sicily 1140 国王的遗产
N个黄金N-1条链,是树结构。盲搜,搜索状态空间:每次切掉一条边后出现的两个子图。问题转化为怎么样表示和比较这些子图。显而易见,其中一个子图是原树的一个子树,另一个子图就是该子树的补图。子树可以用它的根来表示。再考虑如何比较它们的优劣,如果大小不同,结果易得,如果大小一样,则需要进一步处理各自“编号组”,麻烦,分析如下。考虑最简单的情况:子树与另一个子树。将它们各自的编号组表示为序列A
2013-02-19 13:06:53
1242
原创 Sicily 1028 Hanoi Tower Sequence
汉诺塔问题,最经典的解法是递归,但是这道题的数据太大,没有办法实现。实际上这道题要求的是找出某一位置的汉诺块,没有必要完全模拟,而是要找出特定的汉诺塔会出现在哪些位置。观察移动的汉诺塔块的序列,可以发现n第一次出现的序列号为2^(n-1)次方。这可以由汉诺塔的归纳办法归纳证明(递归式为f(n)=f(n-1), n, f(n-1),证明略)。又由递归式可以知道,汉诺再次出现是f(n+1)等式右边
2013-02-17 21:17:43
671
原创 Sicily 1134 积木分发
歌手小姐每一次交给一个小朋友一些积木,总是能拿回更多的积木。所以,如果她最后能和所有的小朋友合影的话,她跟任何一个小朋友合影后,因为比原来有了更多的积木,也能与剩下的小朋友完成合影。所以我一开始写了一个最naive版,用list把各个小朋友的信息存起来,然后顺序扫描,能够完成合影就把他的信息删了,并增加歌手小姐手中的积木数,不断循环直至未合影的小朋友数不再变化。结果超时了。只好稍微处理了一下各个小
2013-02-02 15:31:17
522
原创 Sicily 1024 Magic Island
N个结点N-1条边无孤立点,说明这是图的最小生成树。首先将双向边改为单向边,再DFS搜索,两者可同时进行。#include #include #include using namespace std;typedef set > Node;void traverse(vector &tree, int root, int &longest, int pathCost) {
2013-02-02 15:13:59
636
1
原创 Sicily 1063 Who's the Boss
这道题的题意有误,错在这一句:In fact, you can be absolutely sure that your immediate boss is the person who earns the least among all the employees that earn more than you and are at least as tall as you are.根据这一句,
2013-02-02 14:56:28
453
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人