Origami
Time limit2sMemory limit256 MB
Given an a by b grid, decide whether repeated full-length cuts that discard one piece can leave a rectangle of exactly S cells.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Number theory, Brute force
- Solved
- No attempts yet
Problem
Pasha has loved origami since childhood.
Recently he found a description of a very interesting paper figure online. Its special property is that to make it, you may start with any grid sheet containing exactly cells.
Pasha decided to make it right away, but unfortunately he only has a sheet of size by cells. So Pasha picked up a pair of scissors.
Pasha can cut his current sheet along cell boundaries with one cut that goes all the way across the sheet, splitting it into two rectangular pieces, then throw away one piece and keep working with the other. In this way Pasha can make several cuts.
Help Pasha determine whether he can make cuts so that the resulting sheet is a rectangle containing exactly cells.
Input
The first line contains an integer , the number of test cases in the input. does not exceed 200. The descriptions of the test cases follow.
Each test case is described by a single line. This line contains three positive integers , , : the length and width of Pasha's sheet and the area of the sheet he wants to obtain. Each number does not exceed .
Output
For each of the test cases, print YES on a separate line if Pasha can cut the sheet to obtain a rectangle of area exactly , otherwise print NO.