HDU 2298 Toxophily(公式/三分+二分)】的更多相关文章

Toxophily Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1429    Accepted Submission(s): 739 Problem Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess an…
一个人站在(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)) 由于凸函数有以下…
这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过二分法,没有听说三分法,确实三分法很冷,但是学会了就是学会了,而且他的计算速度并不慢,时间复杂度是log型的,所以推荐学会这种方法,下面是具体的代码实现,包括怎么三分的过程,可以平均分成三段,也可以先分成一半,在接着把后面的一半接着再分一半,下面是后面的这种分法: #include <stdio.h…
题目: Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess and bridge, toxophily, deluxe ballrooms KTV rooms, fishing, climbing, and so on. We all like toxophily. Bob is hooked on toxophily recently. Assume that Bob…
斜抛从(0,0)到(x,y),问其角度. 首先观察下就知道抛物线上横坐标为x的点与给定的点的距离与角度关系并不是线性的,当角度大于一定值时可能会时距离单调递减,所以先三分求个角度范围,保证其点一定在抛物线下方,这样距离和角度的关系就是单调的了,再二分角度即可. /** @Date : 2017-09-23 23:17:11 * @FileName: HDU 2298 三分.cpp * @Platform: Windows * @Author : Lweleth (SoungEarlf@gmail…
A Task Process Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1332    Accepted Submission(s): 656 Problem Description There are two kinds of tasks, namely A and B. There are N workers and the…
Bomb Game Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5396    Accepted Submission(s): 1925 Problem Description Robbie is playing an interesting computer game. The game field is an unbounde…
代码+解析: 1 //题意: 2 //有一个大炮在(0,0)位置,为你可不可以把炮弹射到(x,y)这个位置 3 //题目给你炮弹初始速度,让你求能不能找出来一个炮弹射出时角度满足题意 4 //题解: 5 //由物理公式分析可知: 6 //Vx=v*cos(a) 7 //Vy=v*sin(a) 8 //t=x/Vx=x/(v*cos(a)) 9 //y=-(1/2)*g*t*t+Vy*t=-(1/2)*g*t*t+v*sin(a)*t 10 //一看是一个一元二次函数那他的图像不是先减后增就是先增…
http://acm.hdu.edu.cn/showproblem.php?pid=2298 题意:给出一个x,y,v,问从(0,0)以v为初速度射箭,能否射到(x,y)这个点,如果能,输出最小的射出角度(与x轴),否则输出-1. 思路:首先考虑不能到达的情况,由动能定理mgy > 1 / 2 * m * v * v的时候,就输出-1. 然后可以列出两个式子: x = v * t * cos(θ)  ① y = v * t * sin(θ) - 1 / 2 * g * t * t. ② 把①带入…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2298 #include<bits/stdc++.h> using namespace std; const double pi=acos(-1.0); const double g=9.8; ; int main() { int t; scanf("%d",&t); while (t--) { double x,y,v; scanf("%lf%lf%lf&qu…
题意:n个人,都要去參加活动,每一个人都有所在位置xi和Wi,每一个人没走S km,就会产生S^3*Wi的"不舒适度",求在何位置举办活动才干使全部人的"不舒适度"之和最小,并求最小值. 思路:首先能够得出最后距离之和的表达式最多仅仅有两个极点, 更进一步仅仅有一个极点,否则无最小值. 那么我们就可用三分法或者二分法求解.即对原函数三分或对导数二分就可以. #include<cstdio> #include<cstring> #inclu…
Toxophily Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2555    Accepted Submission(s): 1416 Problem Description The recreation center of WHU ACM Team has indoor billiards, Ping Pang, chess an…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio.h" //最后得到的F(x)函数要么是单调的,要么是先减后增的,有了这个性质,就可以三分了~ #include "string.h" #define N 10005 #define eps 1e-9 #define INF 0x3fffffff struct node { in…
Quoit Design Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 47104    Accepted Submission(s): 12318 Problem Description Have you ever played quoit in a playground? Quoit is a game in which fla…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2063 二分匹配最大匹配数简单题,匈牙利算法.学习二分匹配传送门:http://blog.csdn.net/dark_scope/article/details/8880547 #include <iostream> #include <cstdio> #include <cstring> #include <vector> using namespace std…
Clarke and baton Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5565 Description Clarke is a patient with multiple personality disorder. One day, Clarke split into n guys, named 1 to n. They will play a game ca…
http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中每个x所在的n个函数的最大值的最小值.很拗口吧,显然这题不是组队或者耐心的做是不知道性质的,至少我没看出来.网上说是三分,我画了几个图,确实是.根据二次函数的性质,增长的快慢已经确定了,那的确是单峰的.那就OK了.另外eps的问题1e-8还是wa,1e-9AC.想了下,因为有系数a,b,c的缘故,一…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5646 题意:将n分成k个正整数之和,要求k个数全部相同:并且这k个数的乘积最大为多少?结果mod 1e^9+7; 思路:由于是mod,不能通过模拟进行比较来判断是否为最优解:那么我们就必须直接计算出这个最优解的序列: 由于当a <= b-2时(相等时表示中间空一位),a*b < (a+1)*(b-1);所以最优解序列要不就是一串连续的序列,要不就是中间空一位,分成两段连续的序列: 因为如果存在空格超过…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2493 题意:给你一个圆锥,水平放置,圆锥中心轴与地面平行,将圆锥装满水,在圆锥某一表面开一个小洞,流出来水的体积为V,给你地面直径D,高H,让你求小洞里地面的距离.(保证距离大于等于半径,小于等于直径) 题解:因为流出来水的那部分是一个不规则形状(相当于将圆锥水平切开,截面是一个三角形),我们可以二分答案下降高度r,现在关键是求体积. 然后通过一系列很复杂的积分运算,得出结果: 记得最后求出来的答案要…
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意 :给出n * m的格子,每个格子有两个属性food , prod.对于每一个查询A,B,可以选择某个格子将food属性+A,prod+B,然后以这个格子为中心的正方形两个属性和的最小值最大. http://acm.hdu.edu.cn/showproblem.php?pid=4721 其实很简单的题, 很早就会了,WA了好多天,结果是一个乘号…
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题意 :有三个点,p0,p1,p2.有两个人alice,bob,他们初始位置为p0,现在 alice需要先到p2再到p1,bob是直接到p1.设计一条线路,使得他们初始一起走的路程尽可能地长(之后相遇不算).要求alice走的路程和最短路之差不超过t1,bob不超过t2. http://codeforces.com/contest/8/proble…
Description Suppose that we have a square city with straight streets. A map of a city is a square board with n rows and n columns, each representing a street or a piece of wall. A blockhouse is a small castle that has four openings through which to s…
http://acm.split.hdu.edu.cn/showproblem.php?pid=5726 题意:给出一串数字,现在有多次询问,每次询问输出(l,r)范围内所有数的gcd值,并且输出有多少数量区间的gcd值等于该gcd值. 思路: 第一问的话可以用线段树或RMQ来解决,RMQ的话简单点. 有意思的是第二问,假设我们现在固定左端点,那么往右端扩大区间时,gcd单调不增,并且每次至少减少一倍,所以我们可以二分枚举. #include<iostream> #include<alg…
http://acm.hdu.edu.cn/showproblem.php?pid=4927 给定一个长度为n的序列a,每次生成一个新的序列,长度为n-1,新序列b中bi=ai+1−ai,直到序列长度为1.输出最后的数. n有3000果断用大数,类似杨辉三角推出每个数对最终结果的贡献,利用公式:c[n][m] = c[n][m-1]*(n-m+1)/m防超时 import java.math.BigInteger; import java.util.*; public class Main {…
http://acm.split.hdu.edu.cn/showproblem.php?pid=3586 题意: 给定一个带权无向树,要切断所有叶子节点和1号节点(总根)的联系,每次切断边的费用不能超过上限limit,问在保证总费用<=m下的最小的limit. 思路: 对于上限limit我们可以二分查找.然后就是树形dp,看代码就可以理解的. #include<iostream> #include<algorithm> #include<cstring> #inc…
zxa and leaf 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5682 Description zxa have an unrooted tree with n nodes, including (n−1) undirected edges, whose nodes are numbered from 1 to n. The degree of each node is defined as the number of the edge…
题目链接: pid=2236">Hdu 2236 解题思路: 将行和列理解为二分图两边的端点,给出的矩阵即为二分图中的全部边, 假设二分图能全然匹配,则说明 不同行 不同列的n个元素 区间为(min_edge.max_edge),这些edge是指构成全然匹配的那些边 题目须要求解最小区间长度 我们 能够 二分区间长度(0~100),每次枚举区间的下界 最后得到的maxl 即为答案 代码: #include<iostream> #include<cstdio> #in…
题目链接:点击打开链接 题意:点击打开链接 三分house到shop的距离,二分这条斜边到cinema的距离 #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> #include<math.h> #include<set> #include<queue> #include<vector> #include<…
题目大意:有N串钥匙,M对锁.每串钥匙仅仅能选择当中一把.怎样选择,才干使开的锁达到最大(锁仅仅能按顺序一对一对开.仅仅要开了当中一个锁就可以) 解题思路:这题跟HDU - 3715 Go Deeper 这题的限制比較简单.都是二选一,2-SAT的裸题,仅仅只是加了二分而已 附上HDU - 3715 Go Deeper题解 #include <cstdio> #include <cstring> #include <algorithm> #include <vec…
Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 2427    Accepted Submission(s): 858 Problem Description The shorter, the simpler. With this problem, you should be convinced of this t…