03 2016 档案
摘要:因为数据范围并不大,所以可以枚举。 枚举的方法是枚举二叉树,之后计算每棵树的答案。 枚举的时候,每次选择两个没有父节点的节点连接,n-1次之后即得一棵二叉树。 计算的时候,分别计算两棵子树的宽,再结合本节点天平的宽。 有一个小技巧,由于计算时子程序要返回两个值(最左长度和最右长度),不能直接写成返回
阅读全文
摘要:1 /*UVa 11292 Dragon of Loowater*/ 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int n,m; 8 int main(){ 9 while(scanf("%d%d",&n,&m) && n!=0 && m!=0){ 10 in...
阅读全文
摘要:quicksum Given a string of digits, find the minimum number of additions required for the string to equal some target number. Each addition is the equi
阅读全文
摘要:Given a graph (V,E) where V is a set of nodes and E is a set of arcs in VxV, and an ordering on the elements in V, then the bandwidth of a node v is d
阅读全文
摘要:You have been employed by the organisers of a Super Krypton Factor Contest in which contestants have very high mental and physical abilities. In one s
阅读全文
摘要:A ring is composed of n (even number) circles as shown in diagram. Put natural numbers into each circle separately, and the sum of numbers in two adja
阅读全文
摘要:编程很简单,关键在于数学推导。 ∵x≥y ∴1/x≤1/y ∴1/k=1/x+1/y≤2/y 即y≤2k 又易知y>k 在此范围内枚举即可。 验证时, 由1/k=1/x+1/y 得x=ky/(y-k), 判断上式是否为整数即可。
阅读全文
摘要:由于n很小,枚举起点和终点即可。 由于存在0,不能用“前缀积”数组。
阅读全文
摘要:枚举分母,验证分子。当分子超过五位时停止。注意前导0的处理。
阅读全文
摘要:题意需要几步转化。 关键要自己手画几个图感受一下。 避免攻击离开战场 →1.以敌人为障碍物,找到一条从左到右的通路。 →2.以敌人为路,找到一条从上到下的通路。(如果有一条上下贯通的路,则一定把地图分为左右两部分,即不存在左右通路。) 从每个与上边界相交或相切的圆开始搜索和它相交或相切的圆。如果搜到
阅读全文
摘要:所求路线有两个要求,一是距离最短,二是在一的前提下字母序最小。因此进行BFS时,需要同时顾及两个因素。 保证距离最短时,可以先从终点出发求一遍最短路,这样每次BFS时只要保证下一步的点的最短路比当前点小1,最后求出来的就一定是最短路。 处理字典序时,采用贪心策略,即从头开始每一步都要最小。对一个点操
阅读全文
摘要:算法实现其实很简单,关键需要想明白。 只要边上的标号重复,那就一定可以通过不断的翻转无限延伸。 于是我们可以把每种标号看成一个点,每个正方形看成若干条边(比如,正方形上有两条边标号分别是A+,B-,那就分别连A-→B-,B+→A+,表示如果目前有一条边缘是A-,那么就可以有一个边缘是B-。 如果图中
阅读全文
摘要:OJ地址:洛谷P1981 CODEVS 3292 正常写法是用栈 然而还有超诡异的解法
阅读全文
摘要:离散化+floodfill。 最开始用的dfs结果RE想到可能是堆栈溢出,改用bfs后AC。 由于体积和面积都是从外面看的,可以从外面一圈“空气”开始floodfill,每次遇到雕塑就加上表面积,因为每一块表面积都会且只会和一块空气接触。体积用总体积减去遇到的空气体积即可。 由于坐标较大,需要离散化
阅读全文
摘要:#include #include #include #include #include using namespace std; int ss,n,d[10001],sum=0; int main() { int i,y; bool c=false; cin>>ss>>n; for(i=0;i>d[i]; sort(d,d+n); ...
阅读全文
摘要:洛谷P1093 题目描述 某小学最近得到了一笔赞助,打算拿出其中一部分为学习成绩优秀的前5名学生发奖学金。期末,每个学生都有3门课的成绩:语文、数学、英语。先按总分从高到低排序,如果两个同学总分相同,再按语文成绩从高到低排序,如果两个同学总分和语文成绩都相同,那么规定学号小的同学 排在前面,这样,每
阅读全文
摘要:本章施工仍未完成 现在的时间是3.17 0:28,我困得要死 本来今天(昨天?)晚上的计划是把整个四道题的题解写出来,但是到现在还没写完T4的高效算法,简直悲伤。 尝试了用floyd写T4,终于大功告成AC后,看到别人的解题报告说fl能过只是因为测试数据范围小。 好像主要有三种解法,fl,dij,d
阅读全文
摘要:多项式计算 栈
阅读全文
摘要:无需建树,递归即可。 为什么说是烂题呢? 1.pdf里的样例数据复制过来丢了空格,导致我调了很久都没有发现问题在哪。 2.如样例2所示,4个'-'下面却少一格。 3.空树,即只有'#'需要特殊处理。
阅读全文
摘要:把每个字母看成一个结点,每个单词看成一条从第一个字母到最后一个字母的有向边。把这些单词首尾相接相当于寻找欧拉路径(一笔画)。 则其需满足两个条件:1.忽略边的方向后,原图联通。2.一个点的入度比出度大1,另一个点入度比出度小1,其他点入度和出度相等。
阅读全文
摘要: 拓扑排序,在每个没有访问过的点DFS。之后入栈。 为什么说是个烂题呢?题上没有说m的范围,所以m=0的时候不代表输入结束,不能写while (scanf()&&n&&m)。
阅读全文
摘要:看完题目的长度以后应该就知道这题有多变态了。。。 接下来你将看到代码的长度。。。 无脑BFS+无脑的各种方向转换。 特别注意输出的各种回车空格。 用par数组记录父节点,顺便用来判重(如果没有父节点即为第一次搜到)。 据说用递归输出结果会栈溢出,于是用栈。注意虽然没有搜过起点,起点也要入栈。 每个状
阅读全文
摘要:The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of
阅读全文
摘要:A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadran
阅读全文
摘要:因为复制过来排版很乱,所以上截图。 利用先序的特性可以递归处理。
阅读全文
摘要:1 #include <cstdio> 2 #include <cstring> 3 #include <string> 4 #include <algorithm> 5 #include <cmath> 6 #include <iostream> 7 using namespace std; 8
阅读全文
摘要:Not so Mobile Before being an ubiquous communications gadget, a mobile was just a structure made of strings and wires suspending colourfull things. T
阅读全文
摘要:You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary
阅读全文
摘要:题目如下:Given a sequence of binary trees, you are to write a program that prints a level-order traversal of each tree. In this problem each node of a bin
阅读全文
摘要:描述 9月21日,今天是pink的生日,飘飘乎居士当然要去别人的领土大闹一番啦! 为了收集更多的能量到pink家大闹,飘飘乎居士准备从后花园中取出自己多年积攒的p个能量块。后花园一共被划分n个地区,能量块被分散在里面,现在飘飘乎居士拿出地图,发现自己站在1的地方,而他要做的就是用最短的路程把所有的能
阅读全文
摘要:1644 免费馅饼(巴蜀oj上的编号) 题面: SERKOI最新推出了一种叫做“免费馅饼”的游戏。 游戏在一个舞台上进行。舞台的宽度为W格,天幕的高度为H格,游戏者占一格。开始时,游戏者站在舞台的正中央,手里拿着一个托盘。 游戏开始后,从舞台天幕顶端的格子中不断出现馅饼并垂直下落。游戏者左右移动去接
阅读全文
摘要:#include <iostream> #include <conio.h> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<iomanip> using namespace std; #
阅读全文
摘要:1 /*Hello World*/ 2 #include<iostream> 3 #include<cstdio> 4 #include<cstring> 5 using namespace std; 6 int a,m,n; 7 int mx[5]={0,-1,0,1,0}; 8 int my[5
阅读全文

浙公网安备 33010602011771号