CF460E.Roland and Rose
省选/NOI-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Roland loves growing flowers. He has recently grown a beautiful rose at point (0, 0) of the Cartesian coordinate system. The rose is so beautiful that Roland is afraid that the evil forces can try and steal it.
To protect the rose, Roland wants to build n watch towers. Let's assume that a tower is a point on the plane at the distance of at most r from the rose. Besides, Roland assumes that the towers should be built at points with integer coordinates and the sum of squares of distances between all pairs of towers must be as large as possible. Note, that Roland may build several towers at the same point, also he may build some of them at point (0, 0).
Help Roland build the towers at the integer points so that the sum of squares of distances between all towers is maximum possible. Note that the distance in this problem is defined as the Euclidian distance between points.
罗兰热爱种植花卉。他最近在笛卡尔坐标系的点 (0, 0) 处培育出一朵美丽的玫瑰。这朵玫瑰如此美丽,以至于罗兰担心邪恶势力会试图偷走它。
为了保护这朵玫瑰,罗兰打算建造 n 座瞭望塔。我们假设一座塔是平面上距离玫瑰不超过 r 的一个点。此外,罗兰要求所有塔必须建在整数坐标点上,并且所有塔两两之间距离的平方和应尽可能大。注意,罗兰可以在同一个点上建造多座塔,也可以在点 (0, 0) 处建造部分或全部塔。
请帮助罗兰将这些塔建在整数坐标点上,使得所有塔两两之间距离的平方和达到最大可能值。本题中所指的距离均为两点之间的欧几里得距离。
输入格式
The first line contains two integers, n and r (2 ≤ n ≤ 8; 1 ≤ r ≤ 30).
第一行包含两个整数 n 和 r(2 ≤ n ≤ 8;1 ≤ r ≤ 30)。
输出格式
In the first line print an integer — the maximum possible sum of squared distances. In the i-th of the following n lines print two integers, x__i, y__i — the coordinates of the i-th tower. Each tower must be inside or on the border of the circle with radius r. Note that there may be several towers located at the same point of the plane, also some towers can be located at point (0, 0).
If there are multiple valid optimal arrangements, choose any of them.
第一行输出一个整数——平方距离之和的最大可能值。
接下来的 n 行中,第 i 行输出两个整数 xi, yi —— 第 i 座塔的坐标。每座塔必须位于半径为 r 的圆内或其边界上。注意:平面上可能存在多座塔位于同一点,部分塔也可以位于原点 (0, 0)。
若存在多个合法的最优布局,任选其一即可。
输入输出样例
输入#1
4 1
输出#1
16 0 1 0 1 0 -1 0 -1
输入#2
3 6
输出#2
312 0 6 5 -3 -5 -3
输入解题思路,AI测评打分。不知道怎么写?