CF1468I.Plane Tiling
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:512MB
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} $
给你五个整数 n、dx1、dy1、dx2 和 dy2。你需要选出 n 个互不相同的整数对 (xi,yi),使得对任意整数对 (x,y),都恰好存在一个满足如下约束的三元组 (a,b,i):
{x=xi+a⋅dx1+b⋅dx2,y=yi+a⋅dy1+b⋅dy2.
输入格式
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).
第一行包含一个整数 n(1≤n≤105)。
第二行包含两个整数 dx1 和 dy1(−106≤dx1,dy1≤106)。
第三行包含两个整数 dx2 和 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.
如果无法正确选出 n 对整数,则输出 NO。
否则,在第一行输出 YES,随后输出 n 行,其中第 i 行包含两个整数 xi 和 yi(满足 −109≤xi,yi≤109)。
若存在多种解法,输出任意一种即可。
输入输出样例
输入#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测评打分。不知道怎么写?