题意:让你构造一个n个点的简单多边形,使得所有点是整点,并且所有边长是整数,并且没有边平行于坐标轴。

就利用勾股数,如下图这样构造即可,n为偶数时,只需矩形拼成,n为奇数时,封上虚线边即可。

#include<cstdio>
using namespace std;
struct Point{
int x,y;
Point(const int &x,const int &y){
this->x=x;
this->y=y;
}
Point(){}
}p[1005];
int n,e;
int main(){
// freopen("k.in","r",stdin);
bool tag=0;
int x=-8,y=-19;
scanf("%d",&n);
if(n==3){
puts("0 0\n4 3\n-20 21");
return 0;
}
if(n%2==1){
++n;
tag=1;
}
p[++e]=Point(0,0);
p[++e]=Point(-12,-16);
p[++e]=Point(-8,-19);
p[++e]=Point(4,-3);
for(int i=1;i<=(n-4)/2;++i){
if(i%2==1){
Point a[3];
a[0]=Point(x+4*4,y-4*3);
a[1]=Point(a[0].x+3,a[0].y+4);
a[2]=Point(x+3,y+4);
for(int j=e;j>=e/2+2;--j){
p[j+2]=p[j];
}
p[e/2+1]=a[0];
p[e/2+2]=a[1];
p[e/2+3]=a[2];
x=a[0].x;
y=a[0].y;
e+=2;
}
else{
Point a[3];
a[2]=Point(x-3,y-4);
a[1]=Point(a[2].x-4*4,a[2].y+4*3);
a[0]=Point(a[1].x+3,a[1].y+4);
for(int j=e;j>=e/2+1;--j){
p[j+2]=p[j];
}
p[e/2]=a[0];
p[e/2+1]=a[1];
p[e/2+2]=a[2];
x=a[2].x;
y=a[2].y;
e+=2;
}
}
if(tag){
p[e-1]=p[e];
--e;
}
for(int i=1;i<=e;++i){
printf("%d %d\n",p[i].x,p[i].y);
}
return 0;
}

【构造】Ural Championship April 30, 2017 Problem K. King’s island的更多相关文章

  1. 【哈希表】Ural Championship April 30, 2017 Problem H. Hamburgers

    题意:有n群人,每个人有喜欢的汉堡配方:有m家店,给出每家店的每个汉堡的配方,如果存在某个汉堡,其配料表包含某个人喜欢的配方,则这个人喜欢这个汉堡所在的店家.问你对每群人,输出被喜欢的人数最多的店面是 ...

  2. 【折半枚举】Ural Championship April 30, 2017 Problem G. Glasses with solutions

    题意:有n杯盐溶液,给定每杯里面盐的质量以及盐溶液的质量.问你有多少种方案选择一个子集,使得集合里面的盐溶液倒到一个被子里面以后,浓度为A/B. 折半枚举,暴力搜索分界线一侧的答案数,跨越分界线的答案 ...

  3. XVII Open Cup named after E.V. Pankratiev Grand Prix of Moscow Workshops, Sunday, April 23, 2017 Problem K. Piecemaking

    题目:Problem K. PiecemakingInput file: standard inputOutput file: standard outputTime limit: 1 secondM ...

  4. 【贪心】【后缀自动机】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem E. Enter the Word

    题意:给你一个串,让你从左到右构造这个串,一次操作可以直接在当前串后面添加一个任意字符,或者拷贝当前串的任意一个子串到当前串的后面.问你最少要多少次操作才能构造出这个串. 从前向后贪心,从当前已构造的 ...

  5. 【推导】【构造】XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem E. Space Tourists

    给你n,K,问你要选出最少几个长度为2的K进制数,才能让所有的n位K进制数删除n-2个元素后,所剩余的长度为2的子序列至少有一个是你所选定的. 如果n>K,那么根据抽屉原理,对于所有n位K进制数 ...

  6. 【二分】【三分】【计算几何】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem L. Lines and Polygon

    题意:给你一个凸多边形,和多次询问,每次询问给你一条直线,问你这条直线与凸包上的顶点的最近距离是多少. 记当前询问的直线的斜率为K, 先找到与这条直线距离最远的两个点: 就把凸包所有的边当做有向直线进 ...

  7. 【DFS】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem D. Divisibility Game

    题意:给你一个序列,长度不超过52,每个元素不超过13.让你重新对这个序列排序,sum(i)表示i的前缀和,使得排序过后,对每个i,都有sum(i)%i==0. 深搜,加两个优化:①倒着从后向前搜:② ...

  8. 【线段树】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem J. Jedi Training

    题意:给你一个序列,支持两种操作:单点修改:询问一个区间中所有相邻位置下标奇偶性均不同的子序列中,和最大的是多少. 线段树每个结点维护四个值: 以奇数下标开始到奇数下标结束的最大子序列和: 以偶数下标 ...

  9. XVII Open Cup named after E.V. Pankratiev Stage 14, Grand Prix of Tatarstan, Sunday, April 2, 2017 Problem A. Arithmetic Derivative

    题目:Problem A. Arithmetic DerivativeInput file: standard inputOutput file: standard inputTime limit: ...

随机推荐

  1. Apache服务器添加网站目录不在根目录的情况

    Apache原本根目录: /var/www 需要添加的新的Apache网站目录 /home/*** 在Apache服务器虚拟配置下添加一个站点 <VirtualHost *:> Serve ...

  2. js_setCookie,getCookie和checkcookie函数

    随便说说: cookie和sessionStrong,localStrong在web应用中都有一种存储的功能,也就是说可以把一些数据记录在浏览器.cookie和后两者的主要区别 是cookie是和后端 ...

  3. 【Eclipse】Eclipse中修改项目的映射名称与端口

    1.正常部署(映射的名字为项目名字,端口为8080)

  4. Django rest framework + Vue简单示例

    构建vue项目参考这篇文章https://segmentfault.com/a/1190000008049815 一.创建Vue项目 修改源:npm config set registry https ...

  5. python基础===tkinter学习链接

    http://effbot.org/tkinterbook/tkinter-classes.htm

  6. 机器学习开源项目精选TOP30

    本文共图文结合,建议阅读5分钟. 本文为大家带来了30个广受好评的机器学习开源项目. 640?wx_fmt=jpeg&wxfrom=5&wx_lazy=1 最近,Mybridge发布了 ...

  7. sicily 1001. Fibonacci 2

    1001. Fibonacci 2   Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn-1 + F ...

  8. VPS性能综合测试(5):UnixBench工具介绍

    UnixBench 介绍 UnixBench 是一个类 unix (Unix, BSD, Linux 等) 系统下的性能测试工具,它是一个开源工具.可以用于测试系统主机的性能. UnixBench 进 ...

  9. Go语言用mock server模拟调用(httptest)

    mock是个好东东, 在大项目或大公司,很实用, 因为很多环境不是随时在开发环境可得的. package main import ( "testing" "net/htt ...

  10. nginx安装及配置文件详解

    一)nginx安装及模块讲解 1.1.nginx安装步骤 mkdir /soft wget http://nginx.org/download/nginx-1.12.0.tar.gz tar zxf ...