CF46G.Emperor's Problem
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It happened at the times of the Great Berland Empire. Once the Emperor dreamt that the Messenger from the gods ordered to build a temple whose base would be a convex polygon with n angles. Next morning the Emperor gave the command to build a temple whose base was a regular polygon with n angles. The temple was built but soon the Empire was shaken with disasters and crop failures. After an earthquake destroyed the temple, the Emperor understood that he somehow caused the wrath of gods to fall on his people. He ordered to bring the wise man. When the wise man appeared, the Emperor retold the dream to him and asked "Oh the wisest among the wisest, tell me how could I have infuriated the Gods?". "My Lord," the wise man answered. "As far as I can judge, the gods are angry because you were too haste to fulfill their order and didn't listen to the end of the message".
Indeed, on the following night the Messenger appeared again. He reproached the Emperor for having chosen an imperfect shape for the temple. "But what shape can be more perfect than a regular polygon!?" cried the Emperor in his dream. To that the Messenger gave a complete and thorough reply.
- All the vertices of the polygon should be positioned in the lattice points.
- All the lengths of its sides should be different.
- From the possible range of such polygons a polygon which maximum side is minimal possible must be chosen.
You are an obedient architect who is going to make the temple's plan. Note that the polygon should be simple (having a border without self-intersections and overlapping) and convex, however, it is acceptable for three consecutive vertices to lie on the same line.
此事发生在伟大的伯兰帝国时期。某日,皇帝梦见神使下令建造一座庙宇,其地基为一个具有 n 个角的凸多边形。次日清晨,皇帝便下令建造一座地基为正 n 边形的庙宇。庙宇建成后不久,帝国便接连遭遇灾祸与歉收。一场地震摧毁了庙宇后,皇帝意识到自己无意间触怒了诸神,招致天谴降临于他的子民。他立即下令召来智者。智者到来后,皇帝向他复述了梦境,并问道:“啊,众智者中最睿智者,请告诉我,我究竟如何激怒了诸神?”
“陛下,”智者答道,“依臣之见,诸神震怒,是因为您过于仓促地执行神谕,未能听完全句。”
果然,当夜神使再度现身,斥责皇帝为庙宇选择了不完美的形状。“但还有什么形状能比正多边形更为完美呢!?”皇帝在梦中惊呼道。对此,神使给出了完整而详尽的答复:
- 多边形的所有顶点必须位于格点上;
- 其所有边的长度必须互不相同;
- 在满足上述条件的所有可能多边形中,应选择其最长边长度最小者。
你是一位恭顺的建筑师,即将为这座庙宇绘制规划图。请注意:该多边形必须是简单多边形(边界无自交、无重叠)且为凸多边形;不过,允许三个连续顶点共线。
输入格式
The first line contains the single number n (3 ≤ n ≤ 10000).
第一行包含一个整数 n(3 ≤ n ≤ 10000)。
输出格式
Print "YES" (without quotes) in the first line if it is possible to build a polygon possessing the needed qualities. In the next n lines print integer coordinates of the polygon vertices in the order in which they would be passed counter clockwise. The absolute value of the coordinates shouldn't exceed 109. No two vertices can coincide. It is permitted to print any of the possible solutions. Print "NO" if to build the polygon is impossible.
如果能够构造出满足所需性质的多边形,则在第一行输出 "YES"(不带引号)。接下来的 n 行中,按逆时针顺序输出该多边形各顶点的整数坐标。坐标的绝对值不得超过 109。任意两个顶点不得重合。允许输出任意一种可行解。若无法构造出满足条件的多边形,则输出 "NO"。
输入输出样例
输入#1
3
输出#1
YES 0 0 1 0 0 2
输入#2
3
输出#2
YES 0 1 -1 0 -1 -1
输入解题思路,AI测评打分。不知道怎么写?