Konduktor
InterviewTime limit2sMemory limit128 MB
Count how many times each of N compartments is visited during the first K steps of a back-and-forth walk starting at compartment 1.
- Level
Easy3 of 10
- Topics
- Math, Simulation
- Solved
- No attempts yet
Problem
Conductor Konrad inspects tickets on the trains of one of two large railway companies.
His train has compartments numbered from to . Starting at compartment , Konrad visits the compartments in this order: . In other words, he walks from compartment out to compartment and back again, repeating this back-and-forth motion forever.
Given the number of compartments and the total number of visited compartments , determine how many times Konrad visited each compartment.
Input
The first line contains a natural number (), the number of test sets. The test sets follow, one after another.
Each test set consists of a single line with two natural numbers () and (), separated by a space. Here is the number of compartments and is the total number of visited compartments.
Output
For each test set, print on its own line the integers separated by spaces, where is the number of ticket inspections carried out in compartment .