推荐:数据科学课程和书籍清单以及培训讲座


一亩三分地论坛

 找回密码
 获取更多干活,快来注册

一亩三分地官方iOS手机应用下载
查看: 324|回复: 0
收起左侧

[找工就业] 一道OA题目 求思路

[复制链接] |试试Instant~ |关注本帖
snakefly 发表于 2016-2-4 11:30:22 | 显示全部楼层 |阅读模式

2016(4-6月)-[15]CS硕士+fresh grad 无实习/全职 - Other| 码农类其他@fresh grad应届毕业生

注册一亩三分地论坛,查看更多干货!

您需要 登录 才可以下载或查看,没有帐号?获取更多干活,快来注册

x
来自codeassess  求这里的OA tips.
问题如下:



. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴
Write a program that takes one integer N and an array of N * N elements (the first line contains the integer N and the next N lines contain N integers each, representing the two dimensional array). Your program should give as output the size of the maximum square array (an array of size M * M) that is a magic square and is a sub-array of the inputted array. A magic square is a square of numbers such that when you pick any set of N cells from that square, each cell from the set doesn't share a row or a column with any other cell from that set, and the sum of those N cells is the same for each such possible set of cells.


Example

Case 1:

For the input provided as follows:. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴

2
23 40
9 26

Output of the program will be:

2

Description:

As 23 + 26 is equal to 40 + 9, the inputted array is a magic square, giving us a maximum answer of 2.

Case 2:

For the input provided as follows:

4
-41 -29 2 1
28 40 71 2
11 23 54 3
4 5 6 7 8

Output of the program will be:

3

Description:
. From 1point 3acres bbs
As the inputted array is not a magic square, the answer can not be 4. Looking at all the possible square arrays, we can check that the maximum answer is 3 with the following 3 x 3 array:

-41 -29 2
28 40 71
11 23 54

本版积分规则

关闭

一亩三分地推荐上一条 /5 下一条

手机版|小黑屋|一亩三分地论坛声明

custom counter

GMT+8, 2017-7-27 16:35

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

快速回复 返回顶部 返回列表