很简单。
#include <iostream>
#include <cstring>#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long a, b, c;
cin>>a>>b>>c;
long long r = b - a;
if(c > 0)
{
if(r < 0)
{
cout<<"NO\n";
return 0;
}
}
else if(c < 0)
{
if(r > 0)
{
cout<<"NO\n";
return 0;
}
}
else if(c == 0)
{
if(r == 0)
{
cout<<"YES\n";
return 0;
}
else
{
cout<<"NO\n";
return 0;
}
}
if(r % c == 0)
cout<<"YES\n";
else
cout<<"NO\n";
return 0;
}