• API
• FAQ
• Tools
• Archive
SHARE
TWEET Untitled a guest Sep 17th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. n = int(input())
2. s = int(input())
3. d = [ * n for i in range(n)]
4. for i in range(n):
5.     d[i] = list(map(int, input().split()))
6. sm = [ * (n + 1) for i in range(n + 1)]
7. sm = d
8. for i in range(2, n + 1):
9.     sm[i] = sm[i - 1] + d[i - 1]
10. for i in range(2, n + 1):
11.     sm[i] = sm[i - 1] + d[i - 1]
12. for i in range(1, n):
13.     for j in range(1, n):
14.         sm[i][j] = sm[i - 1][j] + sm[i][j - 1] - sm[i - 1][j - 1] + d[i][j]
15. cnt = 0
16. print(sm)
17. for i in range(1, n + 1):
18.     for j in range(1, n + 1):
19.         for k in range(1, max(i, j) + 1):
20.             if sm[i][j] - sm[i - k][j] - sm[i][j - k] + sm[i - k][j - k] >= s:
21.                 print(i, j, k)
22.                 cnt += 1
23. print(cnt)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top