#P1796. Infinite Sequence

Infinite Sequence

Infinite Sequence

题面翻译

给出三个整数a,b,c,求b是否在以a为第一个数,公差为c的等差数列中。

例如第一个样例,等差数列为1,4,7,10……,7在这个等差数列中,输出YES。(注意,这个等差数列是无限长的)。

题目描述

Vasya likes everything infinite. Now he is studying the properties of a sequence s s , such that its first element is equal to a a ( s1=a s_{1}=a ), and the difference between any two neighbouring elements is equal to c c ( sisi1=c s_{i}-s_{i-1}=c ). In particular, Vasya wonders if his favourite integer b b appears in this sequence, that is, there exists a positive integer i i , such that si=b s_{i}=b . Of course, you are the person he asks for a help.

输入格式

The first line of the input contain three integers a a , b b and c c ( 109<=a,b,c<=109 -10^{9}<=a,b,c<=10^{9} ) — the first element of the sequence, Vasya's favorite number and the difference between any two neighbouring elements of the sequence, respectively.

输出格式

If b b appears in the sequence s s print "YES" (without quotes), otherwise print "NO" (without quotes).

样例 #1

样例输入 #1

1 7 3

样例输出 #1

YES

样例 #2

样例输入 #2

10 10 0

样例输出 #2

YES

样例 #3

样例输入 #3

1 -4 5

样例输出 #3

NO

样例 #4

样例输入 #4

0 60 50

样例输出 #4

NO

提示

In the first sample, the sequence starts from integers 1 1 , 4 4 , 7 7 , so 7 7 is its element.

In the second sample, the favorite integer of Vasya is equal to the first element of the sequence.

In the third sample all elements of the sequence are greater than Vasya's favorite integer.

In the fourth sample, the sequence starts from 0 0 , 50 50 , 100 100 , and all the following elements are greater than Vasya's favorite integer.