【考虑周全+数学变形】【11月赛】Is it a fantastic matrix?
Is it a fantastic matrix?
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 5 Accepted Submission(s) : 2
Problem Description
ways to get the numbers. For every way, if the sum of all selected numbers is always same, you may say the matrix is fantastic.
Input
T cases follow, for every case:
The first line contains two integers n and m. (1 <= n, m <= 50)
Then n lines follows, each line contains m integers. Every number in the matrix will between -100000 and 100000.
Output
Sample Input
3
2 2
1 3
2 4
2 3
1 1 1
1 1 1
2 1
2
3
Sample Output
YES
YES
NO
Source
当k=1 ,jk=1 的时候 a[1][1]+a[t][jt]=a[1][jt]+a[t][1];
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#define oo 0x13131313
using namespace std;
int MAP[60][60];
int main()
{
int T;
cin>>T;
while(T--)
{
int OK=1;
int m,n;
cin>>n>>m;
if(n>m) //懒得写
if(n<m) //懒得写
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
scanf("%d",&MAP[i][j]);
if(n==1||m==1) { printf("NO\n");continue;}
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
if(MAP[i][j]+MAP[1][1]!=MAP[1][j]+MAP[i][1]) OK=0;
if(OK) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}
【考虑周全+数学变形】【11月赛】Is it a fantastic matrix?的更多相关文章
- [LOJ 6249]「CodePlus 2017 11 月赛」汀博尔
Description 有 n 棵树,初始时每棵树的高度为 H_i,第 i 棵树每月都会长高 A_i.现在有个木料长度总量为 S 的订单,客户要求每块木料的长度不能小于 L,而且木料必须是整棵树(即不 ...
- [LOJ 6248]「CodePlus 2017 11 月赛」晨跑
Description “无体育,不清华”.“每天锻炼一小时,健康工作五十年,幸福生活一辈子” 在清华,体育运动绝对是同学们生活中不可或缺的一部分.为了响应学校的号召,模范好学生王队长决定坚持晨跑.不 ...
- [CodePlus 2017 11月赛&洛谷P4058]木材 题解(二分答案)
[CodePlus 2017 11月赛&洛谷P4058]木材 Description 有 n棵树,初始时每棵树的高度为 Hi ,第 i棵树每月都会长高 Ai.现在有个木料长度总量为 S的订单, ...
- [CodePlus 2017 11月赛]晨跑 题解(辗转相除法求GCD)
[CodePlus 2017 11月赛]晨跑 Description "无体育,不清华"."每天锻炼一小时,健康工作五十年,幸福生活一辈子".在清华,体育运动绝 ...
- [BZOJ5109][LOJ #6252][P4061][CodePlus 2017 11月赛]大吉大利,今晚吃鸡!(最短路+拓扑排序+传递闭包+map+bitset(hash+压位))
5109: [CodePlus 2017]大吉大利,晚上吃鸡! Time Limit: 30 Sec Memory Limit: 1024 MBSubmit: 107 Solved: 57[Sub ...
- loj #6250. 「CodePlus 2017 11 月赛」找爸爸
#6250. 「CodePlus 2017 11 月赛」找爸爸 题目描述 小 A 最近一直在找自己的爸爸,用什么办法呢,就是 DNA 比对. 小 A 有一套自己的 DNA 序列比较方法,其最终目标是最 ...
- FOJ 2013 11 月赛
这套题目还是比较吊的,由于我的沙茶,还是很多没有做出来- -! C:逆序数 D:呵呵 A:妈蛋,自己精度没弄好,想到之前GCC的要加eps,就WA了几次后交Visual C++过了!C(n,m)p^m ...
- 「CodePlus 2017 11 月赛」Yazid 的新生舞会(树状数组/线段树)
学习了新姿势..(一直看不懂大爷的代码卡了好久T T 首先数字范围那么小可以考虑枚举众数来计算答案,设当前枚举到$x$,$s_i$为前$i$个数中$x$的出现次数,则满足$2*s_r-r > 2 ...
- 「CodePlus 2017 11 月赛」大吉大利,晚上吃鸡!(dij+bitset)
从S出发跑dij,从T出发跑dij,顺便最短路计数. 令$F(x)$为$S$到$T$最短路经过$x$的方案数,显然这个是可以用$S$到$x$的方案数乘$T$到$x$的方案数来得到. 然后第一个条件就变 ...
随机推荐
- POJ 1469 ZOJ1140 二分匹配裸题
很裸,左点阵n,右点阵m 问最大匹配是否为n #include <cstdio> #include <cstring> #include <vector> usin ...
- Android应用程序启动过程源代码分析
文章转载至CSDN社区罗升阳的安卓之旅,原文地址:http://blog.csdn.net/luoshengyang/article/details/6689748 前文简要介绍了Android应用程 ...
- java.util.concurrent.ExecutionException
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start com ...
- ASP.NET内核几大对象、ASP.NET核心知识(7)--转载
本文的学习流程是这样安排的. 一个简单的GDI小案例 1.说明 如果你想思考如何生成验证码,那么您第一个要解决的问题,一定是.NET动态生成图片问题. //GDI:.Net程序中进行绘图的一些类. 2 ...
- C# using垃圾回收详解
简介 定义一个范围,将在此范围之外释放一个或多个对象. 语法 using (Font font1 = new Font("Arial", 10.0f)) { } C# 语言参考 主 ...
- 简单实用的HTML代码
简单实用的HTML代码 一.HTML各种命令的代码: 1.文本标签(命令) <pre></pre> 创建预格式化文本 <h1></h1> 创建最大的标题 ...
- C++重难点知识
1.顶层const和底层const const int a=10; int b=5; const int *p1=&a; int (*const)p2=&b; p1是顶层const,表 ...
- [TYVJ] P1010 笨小猴
笨小猴 背景 Background NOIP2008复赛提高组第一题 描述 Description 笨小猴的词汇量很小,所以每次做英语选择题的时候都很头疼.但是他找到了一种方法,经试验证明,用这种 ...
- java中Timer计时器使用
1.新建计时器Timer对象 2.给计时器安排任务,schedule方法 3.取消计时器中分配的任务,purge方法 4.终止计时器,cancel方法 注意:如果计时器已经终止,还要给计时器安排任务, ...
- C# json Helper
using System; using System.Collections.Generic; using System.Data; using System.Text; namespace Comm ...