纳斯塔亚掉了 \(n\) 个谷物,每个谷物的重量范围在 \([a - b, a + b]\) 。她猜测谷物的总重量范围在 \([c - d, c + d]\) 。询问她的猜测是否正确。
显然,若 \([n(a-b), n(a+b)]\) 和 \([c - d, c + d]\) 有交,则她的猜测正确。
view
#include <bits/stdc++.h>
typedef long long ll;
void solve(){
int n, a, b, c, d; std::cin >> n >> a >> b >> c >> d;
// [c - d, c + d]
// [n(a-b), n(a+b)]
if (n * (a + b) >= c - d && n * (a - b) <= c + d) std::cout << "YES\n";
else std::cout << "NO\n";
}
int main() {
int _ = 1; std::cin >> _;
while (_--) {solve();}
return 0;
}
- Codeforces Belonogov Nastya Thanks Roundcodeforces belonogov nastya thanks codeforces thanks udebug round educational codeforces round rated codeforces round 911 div codeforces round 864 div codeforces round 887 div codeforces round 863 div codeforces round 913 div codeforces round 915 div codeforces round 912 div