A. Infinite Sequence

题目连接:

http://www.codeforces.com/contest/675/problem/A

Description

Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its first element is equal to a (s1 = a), and the difference between any two neighbouring elements is equal to c (si - si - 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 si = b. Of course, you are the person he asks for a help.

Input

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

Output

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

Sample Input

1 7 3

Sample Output

YES

Hint

题意

A0=a,Ai=Ai-1+b,问你c可不可能出现在这个无限长的数列里面

题解:

水题,用数学方法去做就好了

代码

#include<bits/stdc++.h>
using namespace std; int main()
{
long long a,b,c;
cin>>a>>b>>c;
b-=a;
if(c==0&&b!=0)return puts("NO"),0;
if(c==0&&b==0)return puts("YES"),0;
if(b%c!=0)return puts("NO"),0;
else if(b/c<0)return puts("NO"),0;
return puts("YES"),0;
}

Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题的更多相关文章

  1. Codeforces Round #353 (Div. 2) A. Infinite Sequence

    Vasya likes everything infinite. Now he is studying the properties of a sequence s, such that its fi ...

  2. Codeforces Round #353 (Div. 2) B. Restoring Painting 水题

    B. Restoring Painting 题目连接: http://www.codeforces.com/contest/675/problem/B Description Vasya works ...

  3. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  4. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  5. Codeforces Round #353 (Div. 2) C. Money Transfers (思维题)

    题目链接:http://codeforces.com/contest/675/problem/C 给你n个bank,1~n形成一个环,每个bank有一个值,但是保证所有值的和为0.有一个操作是每个相邻 ...

  6. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

  7. Codeforces Round #188 (Div. 2) A. Even Odds 水题

    A. Even Odds Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/318/problem/ ...

  8. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  9. Codeforces Round #Pi (Div. 2) A. Lineland Mail 水题

    A. Lineland MailTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567/probl ...

随机推荐

  1. Linux多线程的使用一:互斥锁

    多线程经常会在Linux的开发中用到,我想把平时的使用和思考记录下来,一是给自己做个备忘,二是分享给可能会用到的人. POSIX标准下互斥锁是pthread_mutex_t,与之相关的函数有: 1 i ...

  2. Docker技术这些应用场景【转】

    场景一:节省项目环境部署时间 1.单项目打包 每次部署项目到测试.生产等环境,都要部署一大堆依赖的软件.工具,而且部署期间出现问题几率很大,不经意就花费了很长时间. Docker主要理念就是环境打包部 ...

  3. 安装mysql5.5的时候出现Error Nr.1045

    解决办法: 1.删除注册表几个键值:HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\Eventlog\Application\MySQL HKEY_L ...

  4. 利用CSS函数calc(...)实现Web页面左右布局

    前言 因为自己的网站需要,想要做一个左右布局的页面: 左边是导航菜单之类的东西.右边是文档内容(因为最近看的一些软件的文档页面都是这么布局的): 左边固定宽度——300像素.右边使用剩余的宽度: 左边 ...

  5. Python 深拷贝、浅拷贝

    Python中,对象的赋值,拷贝(深/浅拷贝)之间是有差异的,如果使用的时候不注意,就可能产生意外的结果. 首先,对赋值操作我们要有以下认识: 赋值是将一个对象的地址赋值给一个变量,让变量指向该地址( ...

  6. mvn简单命令

    导出maven项目依赖的jar包 mvn dependency:copy-dependencies -DoutputDirectory=lib 编译Java代码 mvn compile eclipse ...

  7. java基础23 Math类和Random类

    一.Math数学类 主要是提供很多数学的公式 1.1.Math类的常用方法 abs(int a):绝对值   ceil(double a):向上取整   floor(double a):向下取整   ...

  8. 洛谷P1120 小木棍(升级版)

    传送门啦 一道经典的搜索剪枝题,不废话,步入正题. 分析: 一.输入时手动过滤不合法的情况 二.很明显我们要枚举把哪些棍子拼接成原来的长棍,而原始长度(原来的长棍的长度)都相等,因此我们可以在 $ d ...

  9. 关于django过滤器的使用

    最近项目中要做分类筛选,其实已经做了这个功能,但是有一个字段是MultiSelectField类型,包含多个值,用户提交的数据是单个值,无法查询出结果, 所以用到了自定义过滤 原代码 class In ...

  10. 安装SHARP MX-3618NC PCL6打印机驱动程序

    第一步,  打开MX-CR3_PCL_PS_1302a_ChineseS_Win8Server2012.exe 驱动程序 此驱动支持Win8.Server2012及以下版本的操作系统,同时兼容Win1 ...