hdu 5432 Pyramid Split 二分】的更多相关文章

Pyramid Split Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=629&pid=1001 Description 小明是城会玩,他有很多底面是正方形的黄金锥体,我们称之为金字塔,它由高度和底面正方形边长可以确定,分别称之为金字塔的高和宽. 为了便于理解,单位统一取米.现在小明有nn个金字塔,已知它们的高和宽,小…
题意:有n个底面是正方形的四棱锥,用一个水平截面将所有四棱锥分成两半,要求上一半体积的和等于下一半,求水平截面的高度,输出整数部分. 解法:二分截面高度.比赛的时候二分写不明白了orz…… 代码: #include<stdio.h> #include<iostream> #include<algorithm> #include<string> #include<string.h> #include<math.h> #include&l…
Problem Description Xiao Ming is a citizen who's good at playing,he has lot's of gold cones which have square undersides,let's call them pyramids. Anyone of them can be defined by the square's length and the height,called them width and height. To ea…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3586 给定n个敌方据点,1为司令部,其他点各有一条边相连构成一棵树,每条边都有一个权值cost表示破坏这条边的费用,叶子节点为前线.现要切断前线和司令部的联系,每次切断边的费用不能超过上限limit,问切断所有前线与司令部联系所花费的总费用少于m时的最小limit.1<=n<=1000,1<=m<=10^6 dp[i]表示i节点为root的这个子树所破坏的最少费用,if(cost[i]…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5726 给你n个数,q个询问,每个询问问你有多少对l r的gcd(a[l] , ... , a[r]) 等于的gcd(a[l'] ,..., a[r']). 先用RMQ预处理gcd,dp[i][j] 表示从i开始2^j个数的gcd. 然后用map存取某个gcd所对应的l r的数量. 我们可以在询问前进行预处理,先枚举i,以i为左端点的gcd(a[i],..., a[r])的种类数不会超过log2(n)…
XOR 游戏 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5715 Description 众所周知,度度熊喜欢XOR运算(XOR百科). 今天,它发明了一种XOR新游戏,最开始,它有一个长度为N的数组,度度熊可以任意添加分割线,将数组划分为M段,且每段长度小于等于L. 当然这是个和XOR有关的游戏,度度熊希望所有分组内异或和的最小值最大. 比如,长度为4的数组{1,2,3,4},L为3,可以划分为{1|2,3,4} 或 {1,2|3,4} 或…
货物运输 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5699 Description 公元2222年,l国发生了一场战争. 小Y负责领导工人运输物资. 其中有m种物资的运输方案,每种运输方案形如li,ri.表示存在一种货物从li运到ri. 这里有n个城市,第i个城市与第i+1个城市相连(这里1号城市和n号城市并不相连),并且从i号城市走到i+1号或者从i+1号走到i号需要耗费1点时间. 由于高科技的存在,小Y想到了一种节省时间的好方案.在X号…
Marriage Match II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4021    Accepted Submission(s): 1309 Problem Description Presumably, you all have known the question of stable marriage match. A…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1281 棋盘游戏 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2905    Accepted Submission(s): 1702 Problem Description 小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽…
Cyclic Tour Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)Total Submission(s): 1197    Accepted Submission(s): 626 Problem Description There are N cities in our country, and M one-way roads connecting them. Now Li…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3813    Accepted Submission(s): 1771 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered…
Sort Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2377    Accepted Submission(s): 610 Problem Description Recently, Bob has just learnt a naive sorting algorithm: merge sort. Now, Bob receiv…
G - Queue HDU - 5493 题目大意:给你n个人的身高和这个人前面或者后面有多少个比他高的人,让你还原这个序列,按字典序输出. 题解: 首先按高度排序. 设每个人在其前面有k个人,设比这个人高有x个人,所以k=min(k,x-k),求出每一个人在他前面比他高的人的数量. 然后用线段树来维护一段区间的空位,因为对于每一个人来说比他高的人肯定都是出现在他后面,所以这个就说明它前面要空出几个空位. 但是线段树可以维护一段区间的空位,没办法准确找出我需要空位为一个准确的数的位置. 这个就可…
Problem Description Xiao Ming is a citizen who's good at playing,he has lot's of gold cones which have square undersides,let's call them pyramids. Anyone of them can be defined by the square's length and the height,called them width and height. To ea…
Bomb Game Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2951    Accepted Submission(s): 984 Problem Description Robbie is playing an interesting computer game. The game field is an unbounded…
题目链接: 传送门 Flyer Time Limit: 1000MS     Memory Limit: 32768 K Description The new semester begins! Different kinds of student societies are all trying to advertise themselves, by giving flyers to the students for introducing the society. However, due…
Function Problem Description   The shorter, the simpler. With this problem, you should be convinced of this truth.    You are given an array A of N postive integers, and M queries in the form (l,r). A function F(l,r) (1≤l≤r≤N) is defined as:F(l,r)={A…
题意:有一个游戏,有n个回合,每回合可以在指定的2个区域之一放炸弹,炸弹范围是一个圈,要求每回合的炸弹范围没有重合.得分是炸弹半径最小的值.求可以得到的最大分数. 思路:二分+2SAT. 二分炸弹范围,再根据有无重合建图,用2SAT判定. #include <cstdio> #include <cmath> #include <vector> #include <cstring> using namespace std; ; struct TwoSAT {…
一个人站在(0,0)处射箭,箭的速度为v,问是否能够射到(x,y)处,并求最小角度. 首先需要判断在满足X=x的情况下最大高度hmax是否能够达到y,根据物理公式可得 h=vy*t-0.5*g*t*t vx=v*cos(a) vy=v*sin(a) t=x/vx 由此可推出:h=x*tan(a)-(g*x*x)/(2*v*v)/cos(a)/cos(a) g,x,v已知,设A=x,B=(g*x*x)/(2*v*v) 原式化为:h=A*tan(a)+(-B/(cos(a)^2)) 由于凸函数有以下…
Problem Description During a programming contest, teams cannot sit close to each other, because then a team might copy the solution of another team. You are given the locations of the teams and the minimum required Euclidian distance between two team…
http://acm.hdu.edu.cn/showproblem.php?pid=5423 题目大意:给你一个树 判断这棵树是否是独特的 一颗树是独特的条件:不存在一颗和它本身不同但相似的树 两颗树相似条件:两颗树中点的数量相等且相对应的点的深度相同 如第2个样例 4 1 2 2 3 1 4 与 4 1 2 1 4 3 4 如图:这两棵树的点的数量相等且相应的点的深度deep相同,所以这两棵树相似,所以样例2存在一颗树与它不同但相似,即不特殊 运用广搜统计每个点的深度 要想一颗树特殊,只有保证…
Radar Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2882    Accepted Submission(s): 1113 Problem Description N cities of the Java Kingdom need to be covered by radars for being in a state of w…
Can you find it? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/10000 K (Java/Others)Total Submission(s): 22312    Accepted Submission(s): 5627 Problem Description Give you three sequences of numbers A, B, C, then we give you a number…
题目链接 给n个数, 定义一个运算f[l,r] = gcd(al, al+1,....ar). 然后给你m个询问, 每次询问给出l, r. 求出f[l, r]的值以及有多少对l', r' 使得f[l, r] = f[l', r']. 第一个很简单, 用倍增的思想就可以了. 然后是第二个, 我们枚举每一个左端点i, 显然f[i, j]是只降不增的. 那么我们可以二分找到所有使得f[i, j]下降的值j. 因为gcd每次至少变为原来的二分之一, 而ai最大为1e9. 所以最多只有log2(1e9)个…
题意:一共有N个城市,一些城市里有金矿,一些城市里有仓库,金矿和仓库都有一个容量,有M条边,每条边是双向的,有一个权值,求将所有金矿里的储量都运送到仓库中,所需要经过的道路中,使最大的权值最小 思路:增设一个超级源点和一个超级汇点,源点与每一个城市相连,容量为黄金数量,汇点与仓库相连,容量为仓库的容量,然后就是二分最小的最大相邻距离,跑最大流验证. #include<stdio.h> #include<string.h> const int N=410; const int inf…
题意有一些绕,但其实就是对于不断变化的i,求以j(0=j<i)使得suffix[j]与suffix[i]的最长公共前缀最长,如果有多个j,则取最小的j. 可以在rank数组中二分,在1-rank[i-1]中二分最接近i的j使得sa[j]小于i,通俗地说就是rank比的rank[i]小,并且位于i之前的后缀.因为这个是左边最接近rank[i]的,所以与suffix[i]的最长公共前缀一定是满足最大的.接下来再根据得到的LCP值,二分一个最小的j.同理,再从rank[i+1]到rank[n]中作类似…
题目链接 Problem Description Alice are given an array A[1..N] with N numbers. Now Alice want to build an array B by a parameter K as following rules: Initially, the array B is empty. Consider each interval in array A. If the length of this interval is le…
题意 给出一排空花瓶 有两种操作  1是 从A花瓶开始放F朵花 如果当前瓶有花就跳过前往下一个 直到花用完或者 瓶子到了最后一个为止 输出 成功放花的第一个和最后一个  如果没有输出 can not....... 2是 清空 一段区间的花 并输出清空了多少朵花 思路:用线段树维护一段区间有多少空花瓶  1操作 就是两次二分 分别求起点和终点   起点  check条件是  query(1,a,mid)>0  终点是  query(1,二分出的起点,mid)>=min(f,query(1,a,n…
无论再来多少次也不可能想到的写法. 二分一个最小的顶端值\(k\),大于设为\(1\)小于等于设为\(0\),可以证猜出来(你跟我说这可以?)如果存在两个连在一起的0/1那么它们会一直往上跑,还可以很容易就想到(容易?????)如果不存在相邻的情况(也就是交叉的那种)那么顶端答案一定是原先左右两边的值之一.. 不管了弃疗了.放代码. #include <bits/stdc++.h> using namespace std; const int N = 200010; int n, a[N &l…
<题目链接> 题目大意: 给定一个整数序列,求出绝对值小于等于k的有序对个数. 解题分析: $O(nlong(n))$的二分很好写,这里就不解释了.本题尺取$O(n)$也能做,并且效率很不错. 尺取: #include <bits/stdc++.h> using namespace std; )]; int main(){ int T,n,k;scanf("%d",&T); while(T--){ scanf("%d%d",&…