CF1468I.Plane Tiling

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given five integers nn , dx1dx_1 , dy1dy_1 , dx2dx_2 and dy2dy_2 . You have to select nn distinct pairs of integers (xi,yi)(x_i, y_i) in such a way that, for every possible pair of integers (x,y)(x, y) , there exists exactly one triple of integers (a,b,i)(a, b, i) meeting the following constraints:

$ \begin{cases} x , = , x_i + a \cdot dx_1 + b \cdot dx_2, \ y , = , y_i + a \cdot dy_1 + b \cdot dy_2. \end{cases} $

输入格式

The first line contains a single integer nn ( 1n1051 \le n \le 10^5 ).

The second line contains two integers dx1dx_1 and dy1dy_1 ( 106dx1,dy1106-10^6 \le dx_1, dy_1 \le 10^6 ).

The third line contains two integers dx2dx_2 and dy2dy_2 ( 106dx2,dy2106-10^6 \le dx_2, dy_2 \le 10^6 ).

输出格式

If it is impossible to correctly select nn pairs of integers, print NO.

Otherwise, print YES in the first line, and then nn lines, the ii -th of which contains two integers xix_i and yiy_i ( 109xi,yi109-10^9 \le x_i, y_i \le 10^9 ).

If there are multiple solutions, print any of them.

输入输出样例

  • 输入#1

    4
    2 0
    0 2

    输出#1

    YES
    0 0
    0 1
    1 0
    1 1
  • 输入#2

    5
    2 6
    1 5

    输出#2

    NO
  • 输入#3

    2
    3 4
    1 2

    输出#3

    YES
    0 0
    0 1
首页