AtCoder-3920
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的更多相关文章
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- AtCoder Grand Contest 001 C Shorten Diameter 树的直径知识
链接:http://agc001.contest.atcoder.jp/tasks/agc001_c 题解(官方): We use the following well-known fact abou ...
- HDU 3920 Clear All of Them I(DP + 状态压缩 + 贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3920 题目大意:你在一个位置用激光枪灭敌人,给你初始位置,下面是2*n个敌人的位置,你一枪能杀两个,可 ...
- AtCoder Regular Contest 082
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #in ...
- AtCoder Regular Contest 069 D
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, w ...
- AtCoder Regular Contest 076
在湖蓝跟衡水大佬们打的第二场atcoder,不知不觉一星期都过去了. 任意门 C - Reconciled? 题意:n只猫,m只狗排队,猫与猫之间,狗与狗之间是不同的,同种动物不能相邻排,问有多少种方 ...
- AtCoder Grand Contest 016
在雅礼和衡水的dalao们打了一场atcoder 然而窝好菜啊…… A - Shrinking 题意:定义一次操作为将长度为n的字符串变成长度n-1的字符串,且变化后第i个字母为变化前第i 或 i+1 ...
- 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, ...
- AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle
https://beta.atcoder.jp/contests/abc075/tasks/abc075_d 题意: 给出坐标平面上n个点的坐标,要求找到一个面积最小的矩形使得这个矩形的边界加上内部的 ...
- AtCoder Beginner Contest 073
D - joisino's travel Time Limit: 2 sec / Memory Limit: 256 MB Score : 400400 points Problem Statemen ...
随机推荐
- Python 基础之socket编程(一)
Python 基础之socket编程(一) 可以进行通信玩儿了,感觉不错不错,网络通信就像打电话,我说一句你听一句之后,你再说一句,我听一句,就这样.....下去了.不扯淡了,来来来,看看今天都搞了点 ...
- 怎样用JS给,option添加“选中”属性
<html> <head> <script> window.onload = function(){ var opts = document.getElementB ...
- JDBC事务的简单使用
在实际功能当中,经常会碰到同时对一组数据进行增加和减少,最常见的就是交易功能. 事务内执行的语句,要么都成功,要么都失败,如果有一句没执行成功,整个事务都不会提交的. import java.sql. ...
- mui 底部导航栏
mui 底部导航栏 <nav class="mui-bar mui-bar-tab " id="nav"> <a class="mu ...
- objc反汇编分析,block函数块为何物?
上一篇向大家介绍了__block变量的反汇编和它的伪代码,本篇函数块block,通常定义成原型(^){},它在反汇编中是什么东西. 我们先定义将要反汇编的例子,为减少篇幅例子采用non-arc环境. ...
- Java描述设计模式(23):访问者模式
本文源码:GitHub·点这里 || GitEE·点这里 一.生活场景 1.场景描述 电竞是游戏比赛达到"竞技"层面的体育项目.利用电子设备作为运动器械进行的.人与人之间的智力对抗 ...
- windows 10安装和配置caffe教程 | Install and Configure Caffe on windows 10
本文首发于个人博客https://kezunlin.me/post/1739694c/,欢迎阅读! Install and Configure Caffe on windows 10 Part 1: ...
- 胜利点组——“萌猿填词”微信小程序评价
此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9860 1.根据(不限于)NABCD评论作品的选题; (1).你的创意解决了 ...
- MySQL 、PDO对象
目录 1, singleton 2, pdo与db 3, singleton获取pdo 4, pdo实现db增删改查 5, pdo异常处理exception 6, pdo预处理prepare 7, p ...
- Scala学习笔记三
scala变量理解: package com.cxy.scala object Hello { def main(args: Array[String]): Unit = { println(&quo ...