diff options
author | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2024-05-28 10:29:13 +0200 |
commit | f05d888a0b621ca4e99e2b0fb6e23c097006fe41 (patch) | |
tree | eebbb2489144112d3288393e354d19375a0aa088 /progs/a878.py |
Init
Diffstat (limited to 'progs/a878.py')
-rw-r--r-- | progs/a878.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/progs/a878.py b/progs/a878.py new file mode 100644 index 0000000..a67f30a --- /dev/null +++ b/progs/a878.py @@ -0,0 +1,17 @@ +def modular_sum(arr, n, m):
+ if (n > m):
+ return True
+ DP = [False for i in range(m)]
+ for i in range(n):
+ if (DP[0]):
+ return True
+ temp = [False for i in range(m)]
+ for j in range(m):
+ if (DP[j] == True):
+ if (DP[(j + arr[i]) % m] == False):
+ temp[(j + arr[i]) % m] = True
+ for j in range(m):
+ if (temp[j]):
+ DP[j] = True
+ DP[arr[i] % m] = True
+ return DP[0]
\ No newline at end of file |