一亩三分地论坛

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

扫码关注一亩三分地公众号
查看: 235|回复: 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.
问题如下:

. 鍥磋鎴戜滑@1point 3 acres


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:. from: 1point3acres.com/bbs

2

Description:

As 23 + 26 is equal to 40 + 9, the inputted array is a magic square, giving us a maximum answer of 2.. 1point 3acres 璁哄潧

Case 2:. 鐗涗汉浜戦泦,涓浜╀笁鍒嗗湴

For the input provided as follows:
. 1point3acres.com/bbs
4
-41 -29 2 1
28 40 71 2. 1point3acres.com/bbs
11 23 54 3
4 5 6 7 8. 鐣欏鐢宠璁哄潧-涓浜╀笁鍒嗗湴

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:

-41 -29 2
28 40 71. visit 1point3acres.com for more.
11 23 54

本版积分规则

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

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

关闭

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

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

custom counter

GMT+8, 2016-12-11 03:47

Powered by Discuz! X3

© 2001-2013 Comsenz Inc. Design By HUXTeam

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