Read problem statements in [Russian] and [Mandarin Chinese]

Chef is playing Need For Speed. Currently, his car is running on a straight road with a velocity $U$ metres per second and approaching a $90^{\circ}$ turn which is $S$ metres away from him. To successfully cross the turn, velocity of the car when entering the turn must not exceed $V$ metres per second.

The brakes of Chef's car allow him to slow down with a deceleration (negative acceleration) not exceeding $A$ metres per squared second. Tell him whether he can cross the turn successfully. The velocity $v$ when entering the turn can be determined from Newton's 2nd law to be $v^{2} = U^{2} + 2 \cdot a \cdot S$ if the car is moving with a uniform acceleration $a$.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first and only line of each test case contains four space-separated integers $U$, $V$, $A$ and $S$.

------  Output ------
For each test case, print a single line containing the string "Yes" if Chef can cross the turn successfully or "No" if he cannot (without quotes).

You may print each character of each string in uppercase or lowercase (for example, the strings "yEs", "yes", "Yes" and "YES" will all be treated as identical).

------  Constraints ------
$1 ≤ T ≤ 10^{5}$
$1 ≤ U, V, A, S ≤ 10^{4}$

------  Subtasks ------
Subtask #1 (100 points): original constraints

----- Sample Input 1 ------ 
3
1 1 1 1
2 1 1 1
2 2 1 1
----- Sample Output 1 ------ 
Yes
No
Yes
----- explanation 1 ------ 
Example case 1: Since $U = V = 1$, Chef does not need to brake and will be able to turn successfully.

Example case 2: The smallest velocity Chef's car can have even with the maximum deceleration is $\sqrt{2 \cdot 2 - 2 \cdot 1 \cdot 1} = \sqrt{2}$, which is greater than the maximum allowed velocity for a safe turn.

Example case 3: The smallest velocity Chef's car can have with the maximum deceleration is again $\sqrt{2}$, which is smaller than the maximum allowed velocity for a safe turn.

Source: codechef | Difficulty: EASY
Tags: Mathematics

Complete search


Solutions:
t = int(input())
for i in range(t):
	(u, v, a, s) = map(int, input().split())
	smallv = u ** 2 - 2 * a * s
	if smallv > v ** 2:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	(u_initial_speed, v_end_speed, a_accelaration, s_distance) = map(int, input().split())
	measure_v = u_initial_speed ** 2 - 2 * a_accelaration * s_distance
	if measure_v > v_end_speed ** 2:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	min_speed = u * u - 2 * a * s
	if v * v >= min_speed:
		print('Yes')
	else:
		print('No')


import math
for i in range(int(input())):
	(U, V, A, S) = map(int, input().split())
	try:
		v = math.sqrt(U ** 2 + 2 * -A * S)
		if v > V:
			print('No')
		else:
			print('Yes')
	except:
		print('Yes')


from math import sqrt, pow
for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	v1 = u ** 2 - 2 * a * s
	if v ** 2 >= v1:
		print('Yes')
	else:
		print('No')


from sys import stdin, stdout
input = stdin.readline
r_int = lambda : int(input())
m_int = lambda : map(int, input().split())
l_int = lambda : list(map(int, input()).split())

def solve():
	(u, v, a, s) = m_int()
	if u * u - 2 * a * s > v * v:
		print('No')
	else:
		print('Yes')

def main():
	n_cases = r_int()
	for _ in range(n_cases):
		solve()
main()


t = int(input())
for i in range(t):
	(U, V, A, S) = [int(x) for x in input().split()]
	limit = (U ** 2 - V ** 2) / (2 * S)
	if limit <= A:
		print('Yes')
	else:
		print('No')


t = int(input())
while t > 0:
	(u, v, a, s) = list(map(int, input().split()))
	res = u ** 2 - 2 * a * s
	v = v ** 2
	if res > v:
		print('No')
	else:
		print('Yes')
	t -= 1


import math
T = int(input())
x = range(T)
for i in x:
	(u, v, a, s) = map(int, input().split())
	y = u ** 2 - 2 * a * s
	if y > v ** 2:
		print('No')
	else:
		print('Yes')


for _ in range(int(input())):
	(U, V, A, S) = map(int, input().split())
	if U <= V:
		print('Yes')
	elif abs(V ** 2 - U ** 2) - 2 * A * S <= 0:
		print('Yes')
	else:
		print('No')


import math
for i in range(int(input())):
	(u, v, a, s) = [int(x) for x in input().split()]
	if u == v:
		print('Yes')
	elif u < v:
		print('Yes')
	elif v * v >= u * u - 2 * s * a:
		print('Yes')
	else:
		print('No')


import math
t = int(input())
for i in range(t):
	(u, v, a, s) = map(float, input().split(' '))
	if v ** 2 >= u ** 2 - 2 * a * s:
		print('Yes')
	else:
		print('No')


import math
for i in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	q = pow(u, 2) - 2 * a * s
	r = 0
	if q < 0:
		q *= -1
		r += 1
	v2 = math.sqrt(q)
	if r == 1:
		v2 *= -1
	if v2 > v:
		print('No')
	else:
		print('Yes')


from math import *
for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	m = u * u - 2 * a * s
	if m <= 0:
		print('Yes')
	else:
		n = sqrt(m)
		if n <= v:
			print('Yes')
		else:
			print('No')


import math
for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	velocity = u * u - 2 * a * s
	if velocity < 0 or velocity ** 0.5 <= v:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(U, V, A, S) = list(map(int, input().split()))
	v = U ** 2 - 2 * A * S
	if v < 0:
		print('Yes')
		continue
	else:
		v = v ** (1 / 2)
	if v <= V:
		print('Yes')
	else:
		print('No')


t = int(input())
for _ in range(0, t):
	(U, V, A, S) = map(int, input().split())
	p = U * U - 2 * A * S
	if p <= 0:
		print('Yes')
		continue
	elif p <= V ** 2:
		print('Yes')
	else:
		print('No')


import numpy as np
for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	if np.sqrt(u ** 2 - 2 * a * s) > v:
		print('No')
	else:
		print('Yes')


n = int(input())
for i in range(n):
	(u, v, a, s) = map(int, input().split())
	c = u * u - 2 * a * s
	if u == v or c <= v * v:
		print('Yes')
	else:
		print('No')


t = int(input())
for i in range(t):
	(u, v, a, s) = list(map(float, input().split(' ')))
	ans = u ** 2 - 2 * a * s
	if ans <= v ** 2:
		print('Yes')
	else:
		print('No')


import math

def check(u, v, a, s):
	if u == 1 and v == 1:
		return 'Yes'
	elif v * v < u * u - 2 * a * s:
		return 'No'
	else:
		return 'Yes'
K = int(input())
for i in range(K):
	(u, v, a, s) = map(int, input().split())
	print(check(u, v, a, s))


import math
t = int(input())
for _ in range(t):
	(u, v, a, s) = map(int, input().split())
	acc = u * u - 2 * a * s
	if u <= v or acc <= v ** 2:
		print('Yes')
	else:
		print('No')


for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split(' '))
	x = (v ** 2 - u ** 2) / (2 * s)
	if u <= v or abs(x) <= a:
		print('Yes')
	else:
		print('No')


import math

def needForSpeed(u, v, a, s):
	print('Yes') if u <= v or u ** 2 - 2 * a * s <= v ** 2 else print('No')
	return None
for _ in range(int(input())):
	(u, v, a, s) = map(int, input().split())
	needForSpeed(u, v, a, s)


def solve():
	(U, V, A, S) = list(map(int, input().split()))
	if U == V:
		print('Yes')
	elif U ** 2 - 2 * A * S <= V ** 2:
		print('Yes')
	else:
		print('No')
for _ in range(int(input())):
	solve()