Computer Science, asked by khan1080, 1 month ago

Tell all the possibilities
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:

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.


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 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 237tanishaqverma
0

Answer:

Explanation:

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:

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.

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 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​

Answered by Sreejanandakumarsl
0

Answer:

Data Format

We know that N no. of packets are listed on the first line of the input.

The second line of input contains N integers separated by spaces, where N is the length of the packet and represents the number of balls in the packet.

Constraints

1<= N <=100

1<= Ni <=10^12

Format of Output

Print the minimum amount of moves necessary to play with the balls.

Final code :

#include<iostream>

using namespace std;

typedef long long ||;

int main()

{

ios_base::sync_with_stdio(false);

cin.tie(NULL);

|| n;

//N packets of Balls

cin>>n;

//single Addition

|| moves=n;

//Pair

for(|| i=2;i<=n;i++)

{

while(n%i==O||n==i)

moves=moves+n/i;

n=n/i;

continue;

}

}

//No. of Moves are

cout<<moves;

return 0;

}

#SPJ3

Similar questions