Hard Cuts | 프로그래밍의 벗 PivotOJ
PivotOJ

Hard Cuts

시간 제한: 2000ms메모리 제한: 256MB출처: NEERC Northern Subregional 2016BOJ 13480
이 문제는 본문 이미지 일부가 표시되지 않습니다. 텍스트만으로 풀이가 어려울 수 있습니다.

문제

Given a rectangle with integer side lengths, your task is to cut it into the smallest possible number of squares with integer side lengths.

입력

The first line contains a single integer T — the number of test cases (1 ≤ T ≤ 3600). Each of the next T lines contains two integers wi, hi — the dimensions of the rectangle (1 ≤ wi, hi ≤ 60; for any i ≠ j, either wi ≠ wj or hi ≠ hj ).

출력

For the i-th test case, output ki — the minimal number of squares, such that it is possible to cut the wi by hi rectangle into ki squares. The following ki lines should contain three integers each: xij , yij — the coordinates of the bottom-left corner of the j-th square and lij — its side length (0 ≤ xij ≤ wi − lij ; 0 ≤ yij ≤ hi −lij ). The bottom-left corner of the rectangle has coordinates (0, 0) and the top-right corner has coordinates (wi, hi).

힌트

[이미지 1]

Example case 1

[이미지 2]

Example case 2

[이미지 3]

Example case 3

예제

예제 1

입력
3
5 3
5 6
4 4
출력
4
0 0 3
3 0 2
3 2 1
4 2 1
5
0 0 2
0 2 2
0 4 2
2 0 3
2 3 3
1
0 0 4
이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.