summaryrefslogtreecommitdiff
path: root/progs/a878.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a878.py')
-rw-r--r--progs/a878.py17
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