diff options
Diffstat (limited to 'progs/a873.py')
-rw-r--r-- | progs/a873.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/progs/a873.py b/progs/a873.py new file mode 100644 index 0000000..dbde9d2 --- /dev/null +++ b/progs/a873.py @@ -0,0 +1,10 @@ +def no_of_subsequences(arr, k):
+ n = len(arr)
+ dp = [[0 for i in range(n + 1)]
+ for j in range(k + 1)]
+ for i in range(1, k + 1):
+ for j in range(1, n + 1):
+ dp[i][j] = dp[i][j - 1]
+ if arr[j - 1] <= i and arr[j - 1] > 0:
+ dp[i][j] += dp[i // arr[j - 1]][j - 1] + 1
+ return dp[k][n]
\ No newline at end of file |