CF1468I.Plane Tiling

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:512MB

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} $

给你五个整数 nn、dx1dx_1、dy1dy_1、dx2dx_2 和 dy2dy_2。你需要选出 nn 个互不相同的整数对 (xi,yi)(x_i, y_i),使得对任意整数对 (x,y)(x, y),都恰好存在一个满足如下约束的三元组 (a,b,i)(a, b, i):

{x = xi+a⋅dx1+b⋅dx2,y = yi+a⋅dy1+b⋅dy2.\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 (1≤n≤1051 \le n \le 10^5).

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

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

第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5)。

第二行包含两个整数 dx1dx_1 和 dy1dy_1(−106≤dx1,dy1≤106-10^6 \le dx_1, dy_1 \le 10^6)。

第三行包含两个整数 dx2dx_2 和 dy2dy_2(−106≤dx2,dy2≤106-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 (−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9).

If there are multiple solutions, print any of them.

如果无法正确选出 nn 对整数,则输出 NO。

否则,在第一行输出 YES,随后输出 nn 行,其中第 ii 行包含两个整数 xix_i 和 yiy_i(满足 −109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9)。

若存在多种解法,输出任意一种即可。

输入输出样例

  • 输入#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

输入解题思路,AI测评打分。不知道怎么写?

首页