From bd8d2defaabfa9581aaa36223dffcd6eebf44325 Mon Sep 17 00:00:00 2001 From: yenru0 Date: Mon, 9 Sep 2024 19:19:16 +0900 Subject: [PATCH] add shebang to run.py and complete 10986.py 11659.py 11660.py --- run.py | 1 + zeta_python/completed/10986.py | 17 +++++++++++++++++ zeta_python/completed/11659.py | 13 +++++++++++++ zeta_python/completed/11660.py | 16 ++++++++++++++++ 4 files changed, 47 insertions(+) create mode 100644 zeta_python/completed/10986.py create mode 100644 zeta_python/completed/11659.py create mode 100644 zeta_python/completed/11660.py diff --git a/run.py b/run.py index 05a62ad..853a558 100644 --- a/run.py +++ b/run.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import os import sys import pathlib diff --git a/zeta_python/completed/10986.py b/zeta_python/completed/10986.py new file mode 100644 index 0000000..e2d46fa --- /dev/null +++ b/zeta_python/completed/10986.py @@ -0,0 +1,17 @@ +import sys +import math + +input = sys.stdin.readline + +if __name__ == "__main__": + N, M = map(int, input().split()) + A = list(map(int, input().split())) + S = [(0, 0)] + C = [0] * 1001 + C[0] = 1 + for i in range(N): + s = ((S[-1][0] + A[i]) % M, i + 1) + S.append(s) + C[s[0]] += 1 + + print(sum([math.comb(c, 2) for c in C])) diff --git a/zeta_python/completed/11659.py b/zeta_python/completed/11659.py new file mode 100644 index 0000000..ae9f069 --- /dev/null +++ b/zeta_python/completed/11659.py @@ -0,0 +1,13 @@ +import sys + +input = sys.stdin.readline + +if __name__ == "__main__": + N, M = map(int, input().split()) + A = list(map(int, input().split())) + S = [0] + for i in range(N): + S.append(S[-1] + A[i]) + for _ in range(M): + i, j = map(int, input().split()) + print(S[j] - S[i - 1]) diff --git a/zeta_python/completed/11660.py b/zeta_python/completed/11660.py new file mode 100644 index 0000000..b594aed --- /dev/null +++ b/zeta_python/completed/11660.py @@ -0,0 +1,16 @@ +import sys + +input = sys.stdin.readline + +if __name__ == "__main__": + N, M = map(int, input().split()) + A = [list(map(int, input().split())) for _ in range(N)] + + S = [[0 for _ in range(N + 1)] for _ in range(N + 1)] + for i in range(N): + for j in range(N): + S[i + 1][j + 1] = S[i][j + 1] + S[i + 1][j] - S[i][j] + A[i][j] + + for _ in range(M): + x1, y1, x2, y2 = map(int, input().split()) + print(S[x2][y2] - S[x2][y1 - 1] - S[x1 - 1][y2] + S[x1 - 1][y1 - 1])