1331. Triple-arm crane

单点时限: 2.0 sec

内存限制: 256 MB

A triple-arm crane places containers on railway wagons. The wagons are numbered in order 1, 2,… . On each wagon at most one container can be put. In one move the crane gets three containers from a storehouse and places them on wagons with numbers i, i+p and i+p+q, or on wagons with numbers i, i+q and i+p+q (for some constants p,q >= 1). The crane has to be programmed in such way, that it loads with containers the first n wagons of the train (the train has n+p+q wagons). The program consists of sequence of instructions. Each instruction describes one move of the crane. Such instruction forms a (x, y, z) triple, where 1 < x < y < z < n+p+q, and determines numbers of wagons, on which the crane has to place the containers. The program is correct if after its execution there is exactly one container on each of the first n wagons of the train.

Task

Write a program, which:

1.reads a description of the crane (numbers p and q) and a number of wagons to be loaded (n),

2.generates a correct program for the crane,

3.writes it out.

输入格式

The first and the only line contains exactly three positive integers separated by single spaces. These are adequately numbers p and q describing parameters of the crane and number n, being the number of the first wagons of the train to be loaded. These numbers satisfy inequalities 1 <= n <= 300000, 2 <= p+q <= 60000.

输出格式

The first line should consist of exactly one integer m being the number of instructions in the program generated. Each of the next m lines should consist of exactly three integers x, y, z separated by single spaces, 1 <= x < y < z <= n+p+q, x <= n, y belongs to {x+p, x+q}, z = x+p+q. These are the numbers of the wagons, on which the crane has to put containers in a consecutive move.

样例

Input
2 3 10
Output
4
1 3 6
2 4 7
5 8 10
9 11 14

1 人解决,2 人已尝试。

1 份提交通过,共有 2 份提交。

9.6 EMB 奖励。

创建: 16 年,8 月前.

修改: 6 年,7 月前.

最后提交: 7 月,4 周前.

来源: POI 2000 II Stage

题目标签