We have a 3×3 grid. A number ci,j is written in the square (i,j), where (i,j) denotes the square at the i-th row from the top and the j-th column from the left.
According to Takahashi, there are six integers a1,a2,a3,b1,b2,b3 whose values are fixed, and the number written in the square (i,j) is equal to ai+bj.
Determine if he is correct.

Constraints

  • ci,j (1≤i≤3,1≤j≤3) is an integer between 0 and 100 (inclusive).

Input

Input is given from Standard Input in the following format:

c1,1 c1,2 c1,3
c2,1 c2,2 c2,3
c3,1 c3,2 c3,3

Output

If Takahashi's statement is correct, print Yes; otherwise, print No.

Sample Input 1

1 0 1
2 1 2
1 0 1

Sample Output 1

Yes

Takahashi is correct, since there are possible sets of integers such as:a1=0,a2=1,a3=0,b1=1,b2=0,b3=1.

Sample Input 2

2 2 2
2 1 2
2 2 2

Sample Output 2

No

Takahashi is incorrect in this case.

Sample Input 3

0 8 8
0 8 8
0 8 8

Sample Output 3

Yes

Sample Input 4

1 8 6
2 9 7
0 7 7

Sample Output 4

No

题解:这一题由于给的数据范围不大,所以可根据关系式,遍历每个整数A;看是否找到使关系式成立的A。如有,则输出Yes,否则输出No

AC代码为:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;

int a[4][4];
int main()
{
for (int i = 1; i <= 3; i++)
{
for (int j = 1; j <= 3; j++)
{
cin >> a[i][j];
}
}
int flag = 1;
for (int k = -1000; k <= 1000; k++)
{
int a2, a3, b1, b2, b3;
int a1 = k;
b1 = a[1][1] - k;
b2 = a[1][2] - k;
b3 = a[1][3] - k;
a2 = a[2][1] - b1;
a3 = a[3][1] - b1;
if (a[2][2] != a2 + b2) flag = 0;
if (a[2][3] != a2 + b3) flag = 0;
if (a[3][2] != a3 + b2) flag = 0;
if (a[3][3] != a3 + b3) flag = 0;
if (flag)
{
break;
}
}
if (flag)
cout << "Yes" << endl;
else
cout << "No" << endl;
return 0;
}

AtCoder-3920的更多相关文章

  1. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  2. AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识

    链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...

  3. HDU 3920 Clear All of Them I(DP + 状态压缩 + 贪心)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3920 题目大意:你在一个位置用激光枪灭敌人,给你初始位置,下面是2*n个敌人的位置,你一枪能杀两个,可 ...

  4. AtCoder Regular Contest 082

    我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...

  5. AtCoder Regular Contest 069 D

    D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...

  6. AtCoder Regular Contest 076

    在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...

  7. AtCoder Grand Contest 016

    在雅礼和衡水的dalao们打了一场atcoder 然而窝好菜啊…… A - Shrinking 题意:定义一次操作为将长度为n的字符串变成长度n-1的字符串,且变化后第i个字母为变化前第i 或 i+1 ...

  8. AtCoder Beginner Contest 069【A,水,B,水,C,数学,D,暴力】

    A - K-City Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement In K-city, ...

  9. AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle

    https://beta.atcoder.jp/contests/abc075/tasks/abc075_d 题意: 给出坐标平面上n个点的坐标,要求找到一个面积最小的矩形使得这个矩形的边界加上内部的 ...

  10. AtCoder Beginner Contest 073

    D - joisino's travel Time Limit: 2 sec / Memory Limit: 256 MB Score : 400400 points Problem Statemen ...

随机推荐

  1. Arduino 基于 ESP8266 配置WIFI模块

    Arduino 基于 ESP8266 配置WIFI模块 使用ESP8266作为服务器,使用浏览器访问该服务器,从而控制LED灯 选择 [文件]->[示例]->[ESP8266WIFI]-& ...

  2. 力扣(LeetCode)两整数之和 个人题解

    不使用运算符 + 和 - ​​​​​​​,计算两整数 ​​​​​​​a .b ​​​​​​​之和. 示例 1: 输入: a = 1, b = 2 输出: 3 示例 2: 输入: a = -2, b = ...

  3. less使用入门

    概要 为什么要有预处理CSS CSS基本上是设计师的工具,不是程序员的工具.在程序员的眼里,CSS是很头痛的事情,它并不像其它程序语言,比如说PHP.Javascript等等,有自己的变量.常量.条件 ...

  4. JAVA语 言 的 特 点

    Java到 底 是 一 种 什 么 样 的 语 言 呢? Java是 一 种 简 单 的 面 象 对 象 的 分 布 式 的 解 释 的 健 壮 的 安 全 的 结 构 中 立 的 可 移 植 的 性 ...

  5. 2016 校招, Android 开发,一个本科应届的坎坷求职之路(转)

    转载出处:http://www.nowcoder.com/discuss/3244?type=2&order=0&pos=1&page=1 和大多数的面经不同,我不是大牛,手头 ...

  6. HTTP基础及telnet简单命令

    一.HTTP概况 20世纪90年代初期,一个主要的新兴应用即万维网(World Wide Web)登上了舞台.Web是一个引起公众注意的因特网应用.Web的应用层协议是超文本传输协议(HTTP),它是 ...

  7. [转载] Docker 实现原理

    目录 Namespaces 进程 网络 libnetwork 挂载点 chroot
 CGroups UnionFS 存储驱动 AUFS 其他存储驱动 总结 原文链接:https://dravenes ...

  8. Python 信息提取-爬虫

    import requests import re from bs4 import BeautifulSoup url = "http://python123.io/ws/demo.html ...

  9. 不止面试02-JVM内存模型面试题详解

    第一部分:面试题 本篇文章我们将尝试回答以下问题: 描述一下jvm的内存结构 描述一下jvm的内存模型 谈一下你对常量池的理解 什么情况下会发生栈内存溢出?和内存溢出有什么不同? String str ...

  10. TensorBoard:可视化学习

    数据序列化 TensorBoard 通过读取 TensorFlow 的事件文件来运行.TensorFlow 的事件文件包括了你会在 TensorFlow 运行中涉及到的主要数据.下面是 TensorB ...