#K78367. Consecutive Group Division
Consecutive Group Division
Consecutive Group Division
You are given a set of cows identified by consecutive IDs. Your task is to determine whether it is possible to divide the cows into M groups such that each group consists of cows with consecutive IDs and all groups have exactly the same number of cows. In other words, if there are N cows, then they can be divided as required if and only if N is divisible by M.
For each test case, if the division is possible, output 1
; otherwise, output 0
.
The mathematical formulation is: output 1 if \( N \mod M = 0 \), and 0 otherwise.
inputFormat
The input is given via standard input (stdin). The first line contains a single integer T representing the number of test cases. Each of the next T lines contains two integers N and M separated by space, where N is the number of cows and M is the number of groups.
outputFormat
For each test case, output a single line containing 1
if it is possible to evenly divide the cows into M consecutive groups, or 0
otherwise. The outputs should be printed via standard output (stdout), one per line.## sample
4
6 3
9 2
10 5
7 1
1
0
1
1
</p>