Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@shashi1iitk | 398 |

@Suniti Jain | 114 |

@ankish2000nayak | 104 |

@gopalsethlnct | 94 |

@esmadhan | 90 |

@senthil1185 | 90 |

@gyanadipta07 | 89 |

@satwikdash2000 | 85 |

@varunmishra3040 | 83 |

@gamec1634 | 82 |

@pj_1721 | 80 |

Complete Leaderboard |

There are N coins and K people. Each of them can propose a method of distribution of the coins amongst themselves when their chance comes and a vote will occur in favour or against his distribution method between all those members. The person proposing that method of distribution wins the vote if he gets equal or more votes in favour than in against his proposal else he loses. Loosing he would be eliminated and then the next member will now propose his method of distribution amongst the remaining members.

Each person while proposing his method of distribution wants to get the maximum number of coins as well as win the vote.

Each person is smart and knows all the possibilities that may occur from their vote and will cast their vote accordingly.

The first proposal will always be given by 1 if he loses will be followed by 2 and so on (till the Kth person).

In the distribution of the 1^{st} person print the amount of coins each of K people is proposed to get so that he wins the vote.

**Input:**

The first line of the test case contains an Integer T, denoting the number of test cases. Each the following T lines will contain two space separated Integers N and K denoting the number of coins and the number of person.

**Output:**

For each of the test case print K space separated Integers denoting the distribution proposed by the 1^{st} person in each line.

**Constraints:**

1<=T<=100

1<=N<=10^9

1<=K<=10^4

N>=K

**Example:**

**Input**

1

100 2

**Output**

100 0

**Explanation:**

To get the maximum coins the 1^{st} person will propose the distribution 100,0 when the vote occurs he will obviously vote for himself and the second person against him. The result of the vote will be 1-1 which means he will survive (tie here means victory) the vote.

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Coins and Game

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.