Computer Science, asked by 18211a1298, 5 hours ago

Jazzy and Cricket Balls (100 Marks)


Jazzy is good with bowling but is not good with studies. His mom wants him to focus on studies too and for this she has found an interesting way. She has brought N packets of balls which may or may not have the same number of balls in them. The balls in a packet are arranged in a linear manner and Jazzy wants to play with the balls.


She will give the balls to Jazzy only if he can tell the maximum number of moves required in which he can get to play with all the balls. There are few conditions though:


1. In one move, Jazzy can divide the number of balls in the packet into an equal number of groups only.


Example: Suppose there are 6 balls in the packet. Jazzy can divide this packet in 3 ways.


1. Two groups of 3 balls each. (3, 3) 2. Three groups of 2 balls each (2, 2, 2)


3. Six groups of 1 ball each.


Note: Dividing a single group into multiple groups of equal number is


considered one move only. 2 Jazzy can get to play with the balls when they are present as a single unit only and not in any group of size greater than 1. Also,


getting to play with a ball is considered a move


Example: In a group there are 2 balls, then Jazzy In a group there are 2 balls, then Jazzy cannot play with them until he further divides them into single-single units.


The length of all the packets/groups should always be an integer.


Example:

Number of Packets, N = 1
Number of balls in packet = 6





Jazzy only cares about playing with the balls and needs your help in finding the maximum number of moves. Can you help him?




Input Format
The first line of input consists of the number of packets, N.
The second line of input consists of N space-separated integers representing the number of balls in the packet (length of the packet), Ni

Constraints
1<= N <=100
1<= Ni <=10^12 (1e12)

Output Format
Print the required number of maximum moves to get to play with the balls.

Sample TestCase 1
Input
2
6 1
Output
11
Explanation

For 6 numbers of balls in a packet, 10 moves are required as explained above.

For 1 ball, only 1 move is required.


Total number of moves = 10 + 1 = 11

Answers

Answered by AradhayDwivedi
3

Answer:

the answer is 11 because ( 1 + 10 = 11 )

Answered by sujan3006sl
0

Answer:

import math

def primefactors(n):

   ans = n

   while (n%2==0):

       n =n//2

       ans+=n

   for i in range(3,int(math.sqrt(n))+2,2):

       while(n%i==0):

           n=n//i

           ans+=n

   if n>2:

       ans+=1

   return ans

n= int(input())

l = list(map(int,input().strip().split(" ")))

op = 0

for d in l:

   op+=primefactors(d)

print(op)

Explanation:

Allow me to explain the meaning in simpler words.

  1. Six balls can be divided by three and two, but if you split it by two, you won't be able to divide it by three to get an equal share, so you'll have to divide it by three.
  2. You'll now have three groups of two balls apiece, for a total of one move.
  3. To make it an equal share, you must split it further.
  4. So 2 will be divided into three equal parts for three groups, and you will have six groups of one ball, and your move count will be three. If you combine movements, your current last move will be 3+1 = 4, and your total ball count will be six, giving you a final answer of ten.
  5. Examples :
  • The answer for 8 ball is 15.
  • The solution for the 14th ball is 22
  • The solution for 16 ball is 31.

#SPJ3

Similar questions