Balloon Count Burst by Ath Kid

 Coding Problem Keys 

 Balloon Count Burst by Ath Kid 

 Problem Statement 

There are N filled balloons each painted with a random number B(i) where i is from 1 to N and the balloons are tied up to a rope in a straight line. M kids who play football arrive and they decide to burst the balloons with the numbers divisible by their jersey numbers J(a) where a is from 1 to M. The program must print the count C of the balloons burst by the A-th Kid (1 <= A <= M).

 Boundary Condition(s) 

1 <= N <= 9999
1 <= M <= 20
1 <= A <= M

 Input Format 

The first line contains N, M, A each separated by a space.
The second line contains N positive integers which denote the numbers on the balloons separated by a space.
The third line contains M positive integers which denote the numbers on the jerseys separated by a space.

 Output Format 

The first line contains C.

 Example Input/Output 1 

 Input 

12 3 2
38 40 11 46 44 48 35 14 39 44 23 45
2 3 11

 Output 

2

 Explanation 

Here A = 2. So we need to print the balloons burst by the 2nd kid.
The 1st kid bursts balloons with numbers which are divisible by 2. So the balloons remaining are 11 35 39 23 45.
The 2nd kid bursts balloons with numbers which are divisible by 3. So the balloons he/she bursts are with numbers 39 and 45 and hence the answer is 2.

 Note: Max Execution Time Limit: 5000 millisecs 

 Solution 

 Programming Language: Python 3 Language 

n,m,a=map(int,input().split())
balloons=list(map(int,input().split()))
jersey=list(map(int,input().split()))
for i in range(m):
    count=0;s=[]
    for j in balloons:
        if(j%jersey[i]==0):
           count+=1
        else:
            s.append(j)
    balloons=s
    if(i==a-1):
        print(count)
        exit()

# Published By PKJCODERS

 (Note: Incase If the code doesn't Pass the output kindly comment us with your feedback to help us improvise.) 

Comments

Popular Posts

Toggle Consonants Adjacent to Vowels

String Pattern - Inverted U

Top Scoring Batsman - TEST ODI 20-20

Java - Method Overriding - Area

Microsoft

Mango Distribution