# Distribute N candies among K people

Contributed by
Nishant Chitkara
Last Updated: 23 Feb, 2023
Easy
0/40
Avg time to solve 15 mins
Success Rate 85 %
Share

## Problem Statement

Suggest Edit

#### Your task is to find the total number of candies every person has at the end.

Detailed explanation ( Input/output format, Notes, Images )
##### Constraints:
``````1 <= T <= 50
1 <= N <= 10^9
1 <= K <= 10^5

Time Limit: 1 sec
``````
##### Sample Input 1:
``````2
7 4
4 1
``````
##### Sample Output 1:
``````1 2 3 1
4
``````
##### Explanation For Sample Input1:
``````Test case 1:
Sanyam has 7 candies and 4 friends.
In the first turn, the first friend gets 1 candy, the second friend gets 2 candies and the third friend gets 3 candies. Now he has used up 6 candies and 1 candy is left. As per the condition, the fourth friend has to be given 4 candies, but there is only 1 left, hence he takes one only.

Test case 2:
As there is only one friend he will get the first candy, then the next two, and then the last one making the count 4.
``````
##### Sample Input 2:
``````2
10 3
3 2
``````
##### Sample Output 2:
``````5 2 3
1 2
``````
Auto
Console