题目链接:http://codeforces.com/problemset/problem/711/B 题目大意: 输入 n ,输入 n*n 的矩阵,有一个占位 0 , 求得将 0 位置换成其他的整数 使得矩阵 行列斜 和全部相等. 代码状态: 一把辛酸泪 2016.09.24 8:14 再次更新  DOWN [昨天晚上的‘杯具’要谨记,做题要看懂题,看清题的要求再做,切记.切记.切记] 补解题思路: 1. 1.1 先特殊判断 n 是否==1,如果等于 1 则直接输出 1 即可 1.2 如果 n…
题目链接: http://codeforces.com/problemset/problem/711/B 题目大意: N*N的矩阵,有且只有一个0,求要把这个矩阵变成幻方要填什么正数.无解输出-1.幻方是每一行每一列和两条主对角线的和都相等. 题目思路: [模拟] 题目没看清外加爆intWA了好多次..罪过. 求出每一行每一列和对角线的和,为0的那个用随意一行的和扣去0的那一行就可以得到.只要验证其余的是否都相等即可. // //by coolxxx //#include<bits/stdc++…
题意:给定n*n个矩阵,其中只有一个格子是0,让你填上一个数,使得所有的行列的对角线的和都相等. 析:首先n为1,就随便填,然后就是除了0这一行或者这一列,那么一定有其他的行列是完整的,所以,先把其他的算出来,然后再作差就算这个数了, 然后再去验证其他的对不对就好了.除了n为1,其他的都是唯一解应该.或者没有. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #i…
简单题. 找一个不存在$0$的行,计算这行的和(记为$sum$),然后就可以知道$0$那个位置应该填的数字(记为$x$). 如果$x<=0$,那么无解,否则再去判断每一行,每一列以及两个斜对角的和是否均为$sum$.需要注意的是$n=1$的时候,直接输出$1$就可以了. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #in…
题目大意:在num[i][j]==0处填一个数使每行,每列,对角线的和相同,若果有多种答案输出一种. 题目思路:模拟 #include<iostream> #include<algorithm> #include<cstring> #include<vector> #include<stdio.h> #include<stdlib.h> #include<queue> #include<math.h> #inc…
挺简单的一道题,但是做的时候没想好就开始写代码了,导致迷之WA,还是要多练习啊. #include <iostream> #include <cstdio> #include <algorithm> #include <queue> #include <set> #define LL long long int using namespace std; LL Map[][]; int main() { cin.sync_with_stdio(fa…
题目链接: B. Chris and Magic Square 题意: 问在那个空位子填哪个数可以使行列对角线的和相等,就先找一行或者一列算出那个数,再验证是否可行就好; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #includ…
B. Chris and Magic Square 题目连接: http://www.codeforces.com/contest/711/problem/B Description ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris notice…
Chris and Magic Square 题目链接: http://codeforces.com/contest/711/problem/B Description ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris noticed that…
ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with integers. Chris noticed that exactly one of the cells in the grid is empty, and to enter Udayland, they need to fi…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output   ZS the Coder and Chris the Baboon arrived at the entrance of Udayland. There is a n × n magic grid on the entrance which is filled with in…
[题目链接]:http://codeforces.com/contest/711/problem/B [题意] 让你在矩阵中一个空白的地方填上一个正数; 使得这个矩阵两个对角线上的和; 每一行的和,每一列的和都相同; [题解] 对于n=1的情况,任意输出一个数字就好; 对于n>1的情况; 先算出不包括空白格子的行的所有元素的和->he; 然后对于其他的可行的行和列,算出它们的和; 一旦与he不一样,直接输出-1无解; 然后包括空白格子的行和列,它们除了那个空白格子的和也要相同->设为sp…
题目:在网格某一处填入一个正整数,使得网格每行,每列以及两条主对角线的和都相等 题目链接:http://codeforces.com/contest/711/problem/B 分析:题目不难,找到要填的那个数填进去,然后循环比较每行每列以及对角线的和是否相等,题目提交上去卡了几次要注意几点 注意:1.答案数据范围$1\leq x \leq 1e18$,要用 long long 2.特殊情况,$n \equiv 1$时,由于一定有要填的数,所以一定有解 3.反正就是要注意看清楚题目和数据边界情况…
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. 输入 The only line contains odd integer n (1 ≤ n ≤ 49). 输出 Print n lines…
Xtreme8.0 - Magic Square 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/magic-square Description Johnny designed a magic square (square of numbers with the same sum for all rows, columns and diagonals i.e. both the main di…
Magic Square Time Limit: 2 Seconds      Memory Limit: 65536 KB In recreational mathematics, a magic square of n-degree is an arrangement of n2 numbers, distinct integers, in a square, such that the n numbers in all rows, all columns, and both diagona…
CodeForces 450B Jzzhu and Sequences (矩阵优化) Description Jzzhu has invented a kind of sequences, they meet the following property: \[f_1=x\] \[f_2=y\] \[f_i=f_{i-1}+f_{i+1}\text {(i>2)}\] You are given x and y, please calculate fn modulo 1000000007 (10…
Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic square,…
  Little Elephant loves magic squares very much. A magic square is a 3 × 3 table, each cell contains some positive integer. At that the sums of integers in all rows, columns and diagonals of the table are equal. The figure below shows the magic squar…
比赛的时候绝壁打麻烦了... 考虑的好麻烦...wa7...还要判断出来的是不是positive的... 好吧..认了.. #include<cstdio> #include <map> #include<iostream> #include<string.h> #include<algorithm> using namespace std; typedef __int64 LL; const int N=5e2+10; LL ma[N][N];…
参考:题解 P3813 [[FJOI2017]矩阵填数] 题目大意: 给定一个 h∗w 的矩阵,矩阵的行编号从上到下依次为 1...h ,列编号从左到右依次 1...w . 在这个矩阵中你需要在每个格子中填入 1...m 中的某个数. 给这个矩阵填数的时候有一些限制,给定 n个该矩阵的子矩阵,以及该子矩阵的最大值 v ,要求你所填的方案满足该子矩阵的最大值为 v . 现在,你的任务是求出有多少种填数的方案满足 n 个限制. 两种方案是不一样的当且仅当两个方案至少存在一个格子上有不同的数.由于答案…
python 增加矩阵行列和维数 方法1 np.r_ np.c_ import numpy as np a = np.array([[1,2,3],[4,5,6],[7,8,9]]) b = np.array([[0,0,0]]) c = np.r_[a,b] d = np.c_[a,b.T] print c print d [[1 2 3] [4 5 6] [7 8 9] [0 0 0]] [[1 2 3 0] [4 5 6 0] [7 8 9 0]] 该方法只能将两个矩阵合并 注意要合并的两…
LINK:矩阵填数 刚看到题目的时候感觉是无从下手的. 可以看到有n<=2的点 两个矩形. 如果只有一个矩形 矩形外的方案数容易计算考虑 矩形内的 必须要存在x这个最大值 且所有值<=x. 直接计算是不易的 需要讨论到底哪个位置有最大值 然后还有重复 很繁琐.可以直接容斥 可以求出<=x的方案数 <=x-1的方案数也可以求出 做差即可得到存在x出现的方案数. 考虑两个矩形 如果不交 那么显然是各算各的 如果相交 讨论相交的这部分到底存在x 然后进一步的讨论从而计算答案. 可以发现这…
[源码下载] 与众不同 windows phone (44) - 8.0 位置和地图 作者:webabcd 介绍与众不同 windows phone 8.0 之 位置和地图 位置(GPS) - Location API 诺基亚地图 示例1.演示新 Location API 的应用GPS/Demo.xaml <phone:PhoneApplicationPage x:Class="Demo.GPS.Demo" xmlns="http://schemas.microsoft…
UiAutomator2.0升级填坑记 SkySeraph May. 28th 2017 Email:skyseraph00@163.com 更多精彩请直接访问SkySeraph个人站点:www.skyseraph.com 啰嗦 Google Android Developers 在2015年3月就发布了UiAutomator 2.0版本(下文简称U2),而公司的核心产品中用到还是UiAutomator老版本(下文简称U1),业界用U2的也不是很多,虽然有诸多问题和不便(如高版本OS中不支持Re…
P3813 [FJOI2017]矩阵填数 shadowice1984说:看到计数想容斥........ 这题中,我们把图分成若干块,每块的最大值域不同 蓝后根据乘法原理把每块的方案数(互不相干)相乘. 怎么计算每块方案数呢 把子矩阵按最大值从小到大排序 暴力预处理好每$k(1<=k<=n)$个矩阵之间的交集.并集 设最大值为$v$的位置的集合大小为$S$ 那么我们算出来(本层)的结果就是v^{|S|} 然鹅我们并没有减去某些矩阵没有到最大值(最大只取到$v-1$)的情况 于是对于每个最大值为$…
#include <iostream> #include <time.h> int main() { srand((unsigned)time(NULL));//srand()就是给rand()提供种子seed ; i < ; i++) { ;//对100取余操作 printf(,num); } printf("\n"); ; }…
Description 给定一个 h*w 的矩阵,矩阵的行编号从上到下依次为 1..h,列编号从左到右依次1..w.在这个矩阵中你需要在每 个格子中填入 1..m 中的某个数.给这个矩阵填数的时候有一些限制,给定 n 个该矩阵的子矩阵,以及该子矩阵的 最大值 v,要求你所填的方案满足该子矩阵的最大值为 v.现在,你的任务是求出有多少种填数的方案满足 n 个限 制.两种方案是不一样的当且仅当两个方案至少存在一个格子上有不同的数.由于答案可能很大,你只需要输出答 案 对 1,000,000,007…
5010: [Fjoi2017]矩阵填数 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 90  Solved: 45[Submit][Status][Discuss] Description 给定一个 h*w 的矩阵,矩阵的行编号从上到下依次为 1..h,列编号从左到右依次1..w.在这个矩阵中你需要在每 个格子中填入 1..m 中的某个数.给这个矩阵填数的时候有一些限制,给定 n 个该矩阵的子矩阵,以及该子矩阵的 最大值 v,要求你所填的方案满…
矩阵填数 Time Limit: 10 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 给定一个 h*w 的矩阵,矩阵的行编号从上到下依次为 1..h,列编号从左到右依次1..w. 在这个矩阵中你需要在每个格子中填入 1..m 中的某个数. 给这个矩阵填数的时候有一些限制,给定 n 个该矩阵的子矩阵,以及该子矩阵的最大值 v,要求你所填的方案满足该子矩阵的最大值为 v. 现在,你的任务是求出有多少种填数的方案满足 n…