#K55047. Smallest Sum of Differences

    ID: 29888 Type: Default 1000ms 256MiB

Smallest Sum of Differences

Smallest Sum of Differences

You are given ( t ) test cases. In each test case, you are provided two integers ( n ) and ( k ) representing the number of participants and the number of groups respectively. Your task is to distribute the ( n ) participants into ( k ) groups as evenly as possible; that is, each group will receive either ( \lfloor n/k \rfloor ) or ( \lfloor n/k \rfloor + 1 ) participants. Consequently, the difference between the maximum and minimum group sizes will be either 0 (if ( n ) is divisible by ( k )) or 1 (if there is a remainder).

For each test case, output 0 if ( n ) is exactly divisible by ( k ); otherwise, output 1. Each test case is independent, and your program should process all the test cases and produce the corresponding answers.

inputFormat

The input is given via standard input (stdin). The first line contains an integer ( t ), the number of test cases. This is followed by ( t ) lines, each containing two space-separated integers ( n ) and ( k ).

outputFormat

For each test case, output a single integer on a separate line: 0 if ( n ) is divisible by ( k ), and 1 otherwise.## sample

1
10 5
0

</p>