山东省第六届省赛 BIGZHUGOD and His Friends II(赛瓦定理)
Description
BIGZHUGOD and his three friends are playing a game in a triangle ground.
The number of BIGZHUGOD is 0, and his three friends are numbered from 1 to 3. Before the game begins, three friends stand on three vertices of triangle in numerical order (1 on A, 2 on B, 3 on C), BIGZHUGOD stands inside of triangle.
Then the game begins, three friends run to the next vertex in uniform speed and in straight direction (1 to B, 2 to C, 3 to A and there speeds may different). And BIGZHUGOD can stand in any position inside the triangle.
When any of his friends arrives at next vertex, the game ends.
BIGZHUGOD and his friends have made an agreement: we assume that the beginning is time 0, if during the game, you can find a moment that BIGZHUGOD can block the sight line of 1 to C, 2 to A, 3 to B. Then each friend has to treat BIGZHUGOD with a big meal.
Now BIGZHUGOD knows the lengths of time that his three friends need run to next vertices t1, t2 and t3. He wants to know whether he has a chance to gain three big meals, of course he wants to know in which exciting moment t, he can block three friends\' sight line.
Input
The first line contains an integer T, indicating the number of test cases (T ≤ 1000).
For each case there are three integer t1, t2, t3 (1 ≤ t1, t2, t3 ≤ 100).
Output
If BIGZHUGOD has a chance to gain big meal from his friends, output "YES" and the exciting moment t rounding to 4 digits after decimal point. Otherwise, output "NO".
Sample Input
2 1 1 1 3 4 6
Sample Output
YES 0.5000
YES 2.0000
题解:
赛瓦定理+二分精度求解
代码:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define is_lower(c) (c >= 'a' && c <= 'z')
#define is_upper(c) (c >= 'A' && c <= 'Z')
#define is_alpha(c) (is_lower(c) || is_upper(c))
#define is_digit(c) (c >= '0' && c <= '9')
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define PI acos(-1)
#define IO \
ios::sync_with_stdio(); \
cin.tie(); \
cout.tie();
#define For(i, a, b) for (int i = a; i <= b; i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const ll inf = 0x3f3f3f3f;
;
const ll inf_ll = (ll)1e18;
const ll maxn = 100005LL;
const ll mod = 1000000007LL;
+ ;
int main() {
int T;
cin >> T;
double t1, t2, t3;
while (T--) {
cin >> t1 >> t2 >> t3;
// 2t^3 = t1*t2*t3 - (t1 * t2 + t2 * t3 + t3 * t1) * t +
// (t1 + t2 + t3) * t^2;
, r = min(t1, min(t2, t3)), t;
) {
t = (l + r) / 2.0;
double y = t1 * t2 * t3 - (t1 * t2 + t2 * t3 + t3 * t1) * t +
(t1 + t2 + t3) * t * t - t * t * t * ;
)
l = t;
else
r = t;
}
printf("YES %.4lf\n", t);
}
}
山东省第六届省赛 BIGZHUGOD and His Friends II(赛瓦定理)的更多相关文章
- 山东省第六届省赛 H题:Square Number
Description In mathematics, a square number is an integer that is the square of an integer. In other ...
- 山东省第六届ACM省赛
A.Nias and Tug-of-War(sort排序) B.Lowest Unique Price(set+map) C.Game!(博弈) D.Stars E.BIGZHUGOD and His ...
- 湖南省第六届省赛题 Biggest Number (dfs+bfs,好题)
Biggest Number 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 You have a maze with obstacles and non-zero di ...
- 山东省第六届ACM省赛 H---Square Number 【思考】
题目描述 In mathematics, a square number is an integer that is the square of an integer. In other words, ...
- 山东省第七届省赛 D题:Swiss-system tournament(归并排序)
Description A Swiss-system tournament is a tournament which uses a non-elimination format. The first ...
- Sdut 2164 Binomial Coeffcients (组合数学) (山东省ACM第二届省赛 D 题)
Binomial Coeffcients TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 输入 输出 示例输入 1 1 10 2 9 ...
- Sdut 2165 Crack Mathmen(数论)(山东省ACM第二届省赛E 题)
Crack Mathmen TimeLimit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take security ...
- FZOJ--2221-- RunningMan 福建第六届省赛
题目链接:http://acm.hust.edu.cn/vjudge/contest/127149#problem/J 题目大意: 因为总共就分三个队,因为两个队都要选取最优的策略,不论B队咋放,要使 ...
- Problem 2214 Knapsack problem 福建第六届省赛
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2214 题目大意:给你T组数据,每组有n个物品,一个背包容量B,每件有体积和价值.问你这个背包容纳的物品最大价值 ...
随机推荐
- ES mapping的写入与查看
Elasticsearch索引mapping的写入.查看与修改 https://blog.csdn.net/napoay/article/details/52012249 首先创建一个索引: curl ...
- Str 函数
Str 函数 Visual Studio 2005 返回数字的 String 表示形式. Public Shared Function Str(ByVal Number As Object) ...
- LeetCode--Remove Linked List Element
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --& ...
- AGC016C +/- Rectangle(构造)
题目大意:给定H,W,h,w四个数,求是否满足矩阵的全部数之和和正数,h行w列之和为负数 如果h和w恰好是H,W的约数,则肯定不存在 否则肯定存在 只需要把h,w内每个元素填的足够大,然后小矩形的最后 ...
- [Leetcode] Add two numbers 两数之和
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...
- [Leetcode] candy 糖果
There are N children standing in a line. Each child is assigned a rating value. You are giving candi ...
- BZOJ3573 [Hnoi2014]米特运输 【贪心】
题目链接 BZOJ3573 题解 题目又臭又长系列 题意:修改尽量少的点权,使得: ①同个节点的所有儿子点权相同 ②任意非叶节点权值等于其儿子权值之和 容易发现一旦任意一个点权值确定,整棵树权值就确定 ...
- 手把手教你通过Eclipse工程配置调用JNI完全攻略
本文地址:http://www.cnblogs.com/wavky/p/JNI.html 当你找到并鬼使神差地打开这个博文的时候,我敢肯定你已经知道什么是JNI,基本概念就不粘贴了. 百度出来的JNI ...
- [NOI2003] 文本编辑器 (splay)
复制炸格式了,就不贴题面了 [NOI2003] 文本编辑器 Solution 对于光标的移动,我们只要记录一下现在在哪里就可以了 Insert操作:手动维护中序遍历结果,即每次取中点像线段树一样一样递 ...
- [codechef MEXDIV]Mex division
题目链接:https://vjudge.net/contest/171650#problem/I 直接用set+dp水过去了... /* 设dp[i]表示前i个做划分满足条件的方案数 有一个显然的转移 ...