CF1468I.Plane Tiling
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given five integers n , dx1 , dy1 , dx2 and dy2 . You have to select n distinct pairs of integers (xi,yi) in such a way that, for every possible pair of integers (x,y) , there exists exactly one triple of integers (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 n ( 1≤n≤105 ).
The second line contains two integers dx1 and dy1 ( −106≤dx1,dy1≤106 ).
The third line contains two integers dx2 and dy2 ( −106≤dx2,dy2≤106 ).
输出格式
If it is impossible to correctly select n pairs of integers, print NO.
Otherwise, print YES in the first line, and then n lines, the i -th of which contains two integers xi and yi ( −109≤xi,yi≤109 ).
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