A. Kirill And The Game #430 (Div. 2)

xiaoxiao2021-02-27  184

A. Kirill And The Game time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

Kirill plays a new computer game. He came to the potion store where he can buy any potion. Each potion is characterized by two integers — amount of experience and cost. The efficiency of a potion is the ratio of the amount of experience to the cost. Efficiency may be a non-integer number.

For each two integer numbers a and b such that l ≤ a ≤ r and x ≤ b ≤ y there is a potion with experience a and cost b in the store (that is, there are (r - l + 1)·(y - x + 1) potions).

Kirill wants to buy a potion which has efficiency k. Will he be able to do this?

Input

First string contains five integer numbers lrxyk (1 ≤ l ≤ r ≤ 1071 ≤ x ≤ y ≤ 1071 ≤ k ≤ 107).

Output

Print "YES" without quotes if a potion with efficiency exactly k can be bought in the store and "NO" without quotes otherwise.

You can output each of the letters in any register.

Examples input 1 10 1 10 1 output YES input 1 5 6 10 1 output NO 给我们l,r,x,y,k让我们求有没有存在a(x<=a<=y)*k等于b(l<=b<=r)不能直接b/k因为可能会是double取整数;所以只能for a*k在不在b的范围里面了。但是明明数据是1^7 两个相乘也才1^14 为什么要用long long #include <iostream> #include<cstdio> #include<algorithm> using namespace std; int main() { long long l,r,x,y,k,flag; while(~scanf("%lld%lld%lld%lld%lld",&l,&r,&x,&y,&k)){ flag=0; for(int i=x;i<=y;i++){ if(k*i>=l&&k*i<=r) { flag=1; printf("YES\n"); break; } } if(flag==0) printf("NO\n"); } return 0; }

转载请注明原文地址: https://www.6miu.com/read-15157.html

最新回复(0)