CF1341A Nastya and Rice
题目描述
有$n$个范围为$[a-b,a+b]$的数,判断他们的和是否可能在$[c-d,c+d]$范围中。
输入有多组数据($1 \le T \le 1000$),保证:
- $1 \le n \le 1000$
- $0 \le b < a \le 1000 $
- $0 \le d < c \le 1000$
输入格式
- 第一行为数据组数$T$。
- 接下来每行五个整数,$n,a,b,c,d$。
输出格式
- 如果所有数的和可能在$[c-d,c+d]$范围中,输出`Yes`,否则输出`No`。
说明/提示
In the first test case of the example, we can assume that each grain weighs $ 17 $ grams, and a pack $ 119 $ grams, then really Nastya could collect the whole pack.
In the third test case of the example, we can assume that each grain weighs $ 16 $ grams, and a pack $ 128 $ grams, then really Nastya could collect the whole pack.
In the fifth test case of the example, we can be assumed that $ 3 $ grains of rice weigh $ 2 $ , $ 2 $ , and $ 3 $ grams, and a pack is $ 7 $ grams, then really Nastya could collect the whole pack.
In the second and fourth test cases of the example, we can prove that it is impossible to determine the correct weight of all grains of rice and the weight of the pack so that the weight of the pack is equal to the total weight of all collected grains.