Timer is Running

Given an integer N, the task is to print M increasing numbers such that the sum of M numbers is equal to N and the GCD of these M numbers is maximum among all possible combinations (or series) of M numbers.

**Note: **If two or more such series are possible then print the series which has smallest first term.

**Input:**

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two integers N and M as input.

**Output:**

For each test case, In new line print the required series, If no series is possible then print "-1".

**Constraints:**

1<=T<=100

1<=M6

**Example:**

**Input:**

2

24 3

6 4

**Output:**

4 8 12

-1

**Explanation:**

```
Input : N = 24, M = 3
Output : 4 8 12
Explanation : (3, 6, 15) is also a series of M numbers which
sums to N, but gcd = 3
(4, 8, 12) has gcd = 4 which is the maximum possible.
```

Author: arun03

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

abnandi04 | 801 |

KshamaGupta | 412 |

srivastavad270 | 223 |

bhavyapratap56 | 206 |

anshusingh20112001 | 181 |

abnandi04 | 776 |

KshamaGupta | 296 |

srivastavad270 | 223 |

bhavyapratap56 | 206 |

afreensartaj131 | 170 |

blackshadows | 5362 |

Ibrahim Nash | 5244 |

akhayrutdinov | 5111 |

mb1973 | 4976 |

Quandray | 4748 |

Login to report an issue on this page.