✔ Subsets of OsAshutosh is a very mischievous student. His mathematics teacher wants to teach him a lesson so, he gave Ashutosh an array of positive integers Ar[a1, a2...., and where ai>0. prímesum is an integer which isequal to sum of all the prime factors of each element in Arr, modulus (10^6). Ashutosh's job is to find no of ways in which a set of primeSum' number of Os can be divided into k subsets modulus(10^9+7).Ashutosh is a little nervous, can you help him get out of this trouble ?Note: A subset can be emptyINPUT:The first line indicates the number of subsets, kThe next line has a single integer n denoting the length of array.Next n lines contain the integers in the array.Input Format for custom testing:2 -> number of subsets, k3 --> length of the array3 --> length of the array for hackerrank representation of integer array followed by elements of the array1OUTPUT:An integer representing the number of ways in which a set of primeSum number of Os can be divided into k subsets mod (10^9+7).Constraints:O<al<=10^61 cun<=10451 <=k<=100
Answers
Answered by
1
Answer:
k = int(input())
n = int(input())
l = []
for i in range(n):
ip = int(input())
l.append(s)
primesum = 0
for i in range(n):
fact = []
for j in range(1,l[i]+1):
if l[i]%j == 0:
fact.append(j)
for k in range(len(fact)):
c = 0
for j in range(1,fact[k]+1):
if fact[k]%j == 0:
c += 1
if c == 2:
primesum += fact[k]
res = []
for i in range(primesum):
res.append(0)
print(len(res)+1)
Explanation:
After i found number of 0's.. i simply printed length + 1.. since subset of a set having only 0's will have possible subset of its length + 1.. i hope this works.. language used is PYTHON 3
Similar questions
English,
5 months ago
Hindi,
5 months ago
Math,
11 months ago
Science,
11 months ago
Psychology,
1 year ago