#C3853. Fair Problem Distribution
Fair Problem Distribution
Fair Problem Distribution
You are given a number of test cases. In each test case, there are n participants and p total problems. The challenge is to decide whether it is possible to distribute the problems in a fair manner.
In particular, a distribution is considered fair if either:
- Each participant receives exactly the same number of problems, i.e. \(p \bmod n = 0\), or
- The distribution can be adjusted so that one participant may receive one problem less than the others, i.e. \(p \bmod n = n-1\).
Output YES
if the problems can be fairly distributed according to the above criteria; otherwise, output NO
.
inputFormat
The first line contains an integer t
representing the number of test cases. Each of the following t
lines contains two space separated integers n
and p
, representing the number of participants and total number of problems respectively.
outputFormat
For each test case, print a single line with either YES
or NO
indicating if a fair distribution is possible.## sample
3
3 8
2 5
4 10
YES
YES
NO
</p>