Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

修改problems/kamacoder/0044.开发商购买土地.md中的python优化暴力代码 #2967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
foreverxiaoyu wants to merge 1 commit into youngyangyang04:master
base: master
Choose a base branch
Loading
from foreverxiaoyu:master
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions problems/kamacoder/0044.开发商购买土地.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -365,23 +365,19 @@ def main():

count = 0
# 行切分
for i in range(n):
# 无需遍历到最后一行,因为切分线始终在行之间
for i in range(n - 1):
for j in range(m):
count += vec[i][j]
# 遍历到行末尾时候开始统计
if j == m - 1:
result = min(result, abs(sum - 2 * count))
result = min(result, abs(sum - 2 * count))

count = 0
# 列切分
for j in range(m):
# 无需遍历到最后一列,因为切分线始终在列之间
for j in range(m - 1):
for i in range(n):
count += vec[i][j]
# 遍历到列末尾时候开始统计
if i == n - 1:
result = min(result, abs(sum - 2 * count))
result = min(result, abs(sum - 2 * count))

print(result)

Expand Down

AltStyle によって変換されたページ (->オリジナル) /