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. js中字符串的常用方法

    一.普通方法 1.字符方法 动态方法:1.str.charAt(index);  返回子字符串,index为字符串下标,index取值范围[0,str.length-1] 动态方法:2.str.cha ...

  2. python 写入execl记录

    记录代码中关于写execl的操作 # 创建execl workbook = xlwt.Workbook(encoding='utf8') # 创建样式实例 style = xlwt.XFStyle() ...

  3. php 中更简洁的三元运算符 ?:

    PHP 三元运算符是对参数赋值时候的一个简洁的主要用法. 一个主要的用法: PHP 三元运算符能够让你在一行代码中描述判定代码, 从而替换掉类似以下的代码: <?php if (isset($v ...

  4. python基础学习之路No.4 数据转换以及操作

    练习python的时候经常会用到一些不同数据类型之间的转换操作 搜集了一些资料,整理如下 函数 描述 int(x [,base]) 将x转换为一个整数 long(x [,base] ) 将x转换为一个 ...

  5. Mat结构

    主要是记录一下大牛的博客,再次感谢这些无私的博主. 这篇博客http://blog.csdn.net/yang_xian521/article/details/7107786中,我觉得要注意的是Mat ...

  6. ThinkPHP文件目录说明

    1.ThinkPHP文件包下目录结构说明 2.ThinkPHP文件目录下文件说明 3.Conf目录下 4.Library目录

  7. supervisor管理uwsgi

    1. 前言 传统的管理uwsgi服务: 1. 通过shell脚本来编写start restart stop函数来控制 2. 比较麻烦,有时候控制写的烂,还会出现意想不到的错误 supervisor进行 ...

  8. Ubuntu 搭建docker registry 私有仓库

    一.为什么要搭建 docker 私有仓库 原因有几个: 项目需要,不希望将项目放到 docker hub 上. 环境需求,考虑网络.效率的问题,希望在私有服务器上建立自用的仓库,提高便利性和访问速度. ...

  9. PivotGridControl控件应用

    一.概述 PivotGridControl是DevExpress组件中的一个重要控件,在数据多维分析方面具有强大的功能,它不仅可以分析数据库中的数据,而且还能够做联机分析处理(OLAP),并且支持多种 ...

  10. 【51nod】1559 车和矩形

    题解 离线读入,我们发现一个矩形能被保护,矩形内部所有列上必定有一辆车,或者所有行上必定有一辆车 分两次进行处理 第一次按照横坐标把车加进去,然后查询最大横坐标在这个位置的矩形,纵坐标区间里的车出现位 ...