HDU 5758 Explorer Bo】的更多相关文章

[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5758 [题目大意] 给出一棵树,每条路长度为1,允许从一个节点传送到任意一个节点,现在要求在传送次数尽量少的情况下至少经过每条路一遍啊,同时最小化走过的路程总长度.输出路程总长度. [题解] 首先,对于传送次数尽量少这个条件,我们很容易发现,当且仅当每次出发点和终止点都是叶节点的时候,是最少的,当然在叶节点无法两两匹配的时候,再多走一条链. 然后就是叶节点的匹配问题,使得匹配后的叶节点连线覆盖全…
思维,树形$dp$. 首先选择一个度不为$0$的节点作为根节点,将树无根转有根. 这题的突破口就是要求瞬间移动的次数最少. 次数最少,必然是一个叶子节点走到另一个叶子节点,然后瞬间移动一次,再从一个叶子节点走到另一个叶子节点,然后瞬间移动一次…… 因为叶子节点总数可能是奇数,可能是偶数,那么接下来要分类讨论一下了. 叶子节点总数为偶数: 这种情况下,叶子节点可以两两配对.如果 下面叶子节点个数是偶数,那么$<u,v>$这条边通过的次数就是$2$:如果$v$下面叶子节点个数是偶数,那么$<…
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y which satisfies fy(n)=1. note:f1(n)=f(n),fy(n)=f(fy−1(n)) It is a pity that Bo can only use 1 unit…
Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequences h1∼hn and c1∼cn. h1∼hn is a permutation of 1∼n. particularly, h0=hn+1=0. We define the expression [condition] is 1 when condition is True,is 0 whe…
Teacher Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geography teacher in the school.One day in his class,he marked N points in the map,the i-th point is at (Xi,Yi).He wonders,whether there is a tetrad (A,B,C,…
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2221    Accepted Submission(s): 882 Problem Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y wh…
Rower Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 Description There is a river on the Cartesian coordinate system,the river is flowing along the x-axis direction. Rower Bo is placed at (0,a) at first.He wants to get to origin (0,0) by boa…
Teacher Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 Description Teacher BoBo is a geography teacher in the school.One day in his class,he marked N points in the map,the i-th point is at (Xi,Yi).He wonders,whether there is a tetrad (A,B,C,…
Permutation Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequences h1∼hn and c1∼cn. h1∼hn is a permutation of 1∼n. particularly, h0=hn+1=0. We define the expression [condition] is 1 when condition is True,is 0 whe…
Sqrt Bo 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f(n)=⌊n−−√⌋. Bo wanted to know the minimum number y which satisfies fy(n)=1. note:f1(n)=f(n),fy(n)=f(fy−1(n)) It is a pity that Bo can only use 1 unit…
传送门 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Special Judge Problem DescriptionThere is a river on the Cartesian coordinate system,the river is flowing along the x-axis direction. Rower Bo is placed at $(0,a…
Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1014    Accepted Submission(s): 561 Problem Description Teacher BoBo is a geography teacher in the school.One day in his class,he mar…
1010 Rower Bo 首先这个题微分方程强解显然是可以的,但是可以发现如果设参比较巧妙就能得到很方便的做法. 先分解v_1v​1​​, 设船到原点的距离是rr,容易列出方程 \frac{ dr}{ dt}=v_2\cos \theta-v_1​dt​​dr​​=v​2​​cosθ−v​1​​ \frac{ dx}{ dt}=v_2-v_1\cos \theta​dt​​dx​​=v​2​​−v​1​​cosθ 上下界都是清晰的,定积分一下: 0-a=v_2\int_0^T\cos\thet…
这里是一个比较简单的问题:考虑每个数对和的贡献.先考虑数列两端的值,两端的摆放的值总计有2种,比如左端:0,大,小:0,小,大:有1/2的贡献度.右端同理. 中间的书总计有6种可能.小,中,大.其中有两种对答案有贡献,即1/3的贡献度.加和计算可得到答案. Permutation Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s):…
Sqrt Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 980    Accepted Submission(s): 452 Problem Description Let's define the function f(n)=⌊n√⌋. Bo wanted to know the minimum number y which…
Teacher Bo Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 752    Accepted Submission(s): 412 Problem Description Teacher BoBo is a geography teacher in the school.One day in his class,he mark…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5761 题目大意: 船在(0,a),船速v1,水速v2沿x轴正向,船头始终指向(0,0),问到达(0,0)用时,无解输出Infinity. 题目思路: [数学] 说是数学其实更像物理. 很明显v1<=v2时无解. 这道题列积分方程然后解出来式子是t=a*v1/(v12-v22). 我列积分方程的时候少了一个式子没解出来. 可以看看半根毛线的.http://images2015.cnblogs.com…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5762 题目大意: 给n个点,坐标范围0~m(n,m<=105),求是否存在2个点对满足哈夫曼距离相等. 题目思路: [模拟] 乍一看n2绝对T了,但是细想之下发现,坐标范围只有105,那么哈夫曼距离最多就2x105种,所以当循环超出这个范围时肯定能找到解(抽屉原理). // //by coolxxx // #include<iostream> #include<algorithm&g…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 题目大意: 定义f(n)=⌊√n⌋,fy(n)=f(fy-1(n)),求y使得fy(n)=1.如果y>5输出TAT.(n<10100) 题目思路: [模拟] 5层迭代是232,所以特判一下层数是5的,其余开根号做.注意数据有0. 队友写的. #include<stdio.h> #include<string.h> #include<math.h> int…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 题目大意: 两个序列h和c,h为1~n的乱序.h[0]=h[n+1]=0,[A]表示A为真则为1,假为0. 函数f(h)=(i=1~n)∑ci[hi>hi−1 && hi>hi+1] 现在给定c的值,求f(h)的期望. 题目思路: [数学] 头尾的概率为1/2,中间的概率为1/3,直接求和. // //by coolxxx // #include<iostream&g…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5755 [题目大意] 一个n*m由0,1,2组成的矩阵,每次操作可以选取一个方格,使得它加上2之后对3取模,周围的四个方格加上1后对3取模,请你在n*m操作次数内让整个矩阵变成0.输出一种方案. [题解] 枚举第一行的方式显然是不行的,因为3的30次方显然不是可以承受的范围,考虑如果存在第0行元素,那么这一行的最终状态就是第一行的操作次数,因为每个格子很明显只会由第一行对应的正下方的格子影响,我们…
题意自己看题目吧,挺短的. 思考过程:昨天感觉一天不做题很对不起自己,于是晚上跑到实验室打开别人树形dp的博客做了上面最后一个HDU的题,也是个多校题..一开始没有头绪了很久,因为起点不固定,所以这1e5的数据要跑的话就有很多很多转移,但是状态又不可能定义得很复杂..然后后来就想到和叶子有关系.就这样停滞不前了很久.半夜看别人博客感觉看懂了,其实也没比没看博客前多懂多少.我只想到了肯定是一个叶子到另一个叶子然后跳一下到另一个叶子然后继续这样做.今天中午又想了很久.首先画样例是关键,学了别人的dp…
http://acm.hdu.edu.cn/showproblem.php?pid=5755 题意: n*m矩阵,每个格有数字0/1/2 每选择一个格子,这个格子+2,4方向相邻格子+1 如何选择格子,可以使每个格子的数最后 %3=0 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; ; int n,m,t; ][]; ]; int turn(int i,int j)…
Swipe Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 455    Accepted Submission(s): 111 Problem Description “Swipe Bo” is a puzzle game that requires foresight and skill. The main character…
Life Winner Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 1019    Accepted Submission(s): 373 Problem Description Bo is a "Life Winner".He likes playing chessboard games with his gir…
Rower Bo Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 641    Accepted Submission(s): 199Special Judge Problem Description ,and the speed of the water flow is v2.He will adjust the direction…
题目:传送门. 题意:平面上有n个点,问是否存在四个点 (A,B,C,D)(A<B,C<D,A≠CorB≠D)使得AB的横纵坐标差的绝对值的和等于CD的横纵坐标差的绝对值的和,n<10^5,点的坐标值m<10^5. 题解:表面上这道题复杂度是O(n^2)会超时的,而实际上这些坐标差绝对值的和最大是2*10^5,所以复杂度不是O(n^2),而是O(min(n^2,m)),这就是著名的鸽笼原理. #include <iostream> #include <cstdio…
题目:传送门. 题意:一个很大的数n,最多开5次根号,问开几次根号可以得到1,如果5次还不能得到1就输出TAT. 题解:打表题,x1=1,x2=(x1+1)*(x1+1)-1,以此类推.x5是不超过long long的,判断输出即可. #include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; typedef long long…
将起始点.终点和钥匙统一编号,预处理: 1.起始点到所有钥匙+终点的最短路 2.所有钥匙之间两两的最短路 3.所有钥匙到终点的最短路 将起始点和所有钥匙四方向出发设为起点BFS一遍,求出它到任意点任意方向的最短路dp[i][j][k].(即到点(i,j)且方向为k的最短路),BFS时需要注意: 1.UDLR有可能组成死循环 2.转向符在墙边并且指向了墙时,无法重新选择方向.例如这个: S...L#E 3.只有豆腐块滑动碰到墙停止了之后,才能把这个点的坐标加入队列.在滑动过程中经过的点都不需要加入…
我是参考这一篇写的:http://blog.csdn.net/fsss_7/article/details/52049474 一点感想:dp[i][0]代表以这个点为根的且总叶子数为偶数个叶子的答案 考虑每条树边的贡献,贪心的想,肯定是每条树边出现的次数越少越好 由于树链肯定从一个叶子到另外一个叶子的,那么可以想到 1:考虑每条树边下面的子树,如果有奇数个节点,那么出来一条边就可以了,剩下的自己匹配就好 2:如果是偶数条边,出来两条就行了,如果多余两条不如两条更优,少于两条,不符合题意 dp[i…