303489: CF675A. Infinite Sequence

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

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 $ , such that its first element is equal to $ a $ ( $ s_{1}=a $ ), and the difference between any two neighbouring elements is equal to $ c $ ( $ s_{i}-s_{i-1}=c $ ). In particular, Vasya wonders if his favourite integer $ b $ appears in this sequence, that is, there exists a positive integer $ i $ , such that $ s_{i}=b $ . Of course, you are the person he asks for a help.

输入输出格式

输入格式


The first line of the input contain three integers $ a $ , $ b $ and $ c $ ( $ -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 $ appears in the sequence $ s $ print "YES" (without quotes), otherwise print "NO" (without quotes).

输入输出样例

输入样例 #1

1 7 3

输出样例 #1

YES

输入样例 #2

10 10 0

输出样例 #2

YES

输入样例 #3

1 -4 5

输出样例 #3

NO

输入样例 #4

0 60 50

输出样例 #4

NO

说明

In the first sample, the sequence starts from integers $ 1 $ , $ 4 $ , $ 7 $ , so $ 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 $ , $ 50 $ , $ 100 $ , and all the following elements are greater than Vasya's favorite integer.

Input

题意翻译

给出三个整数a,b,c,求b是否在以a为第一个数,公差为c的等差数列中。 例如第一个样例,等差数列为1,4,7,10……,7在这个等差数列中,输出YES。(注意,这个等差数列是无限长的)。

加入题单

上一题 下一题 算法标签: