一亩三分地论坛

 找回密码
 获取更多干货,去instant注册!

扫码关注一亩三分地公众号
查看: 250|回复: 0
收起左侧

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

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

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

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

您需要 登录 才可以下载或查看,没有帐号?获取更多干货,去instant注册!

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

. 1point3acres.com/bbs
. From 1point 3acres bbs
. 1point3acres.com/bbs
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.

. 1point 3acres 璁哄潧
Example

Case 1:
. 1point3acres.com/bbs
For the input provided as follows:

2-google 1point3acres
23 40-google 1point3acres
9 26

Output of the program will be:

2-google 1point3acres

Description:

As 23 + 26 is equal to 40 + 9, the inputted array is a magic square, giving us a maximum answer of 2.
.鏈枃鍘熷垱鑷1point3acres璁哄潧
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
-google 1point3acres
Output of the program will be:

3

Description:
鏉ユ簮涓浜.涓夊垎鍦拌鍧.
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:
. From 1point 3acres bbs
-41 -29 2
28 40 71
11 23 54

本版积分规则

请点这里访问我们的新网站:一亩三分地Instant.

Instant搜索更强大,不扣积分,内容组织的更好更整洁!目前仍在beta版本,努力完善中!反馈请点这里

关闭

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

手机版|小黑屋|一亩三分地论坛声明 ( 沪ICP备11015994号 )

custom counter

GMT+8, 2017-1-25 05:37

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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