CodeForces-749B
给定3个坐标,求可能构成平行四边形的第四个点,枚举两个点,根据这两个点的横纵坐标差,来得到第四个点的坐标,注意生成的坐标需要判重。
AC代码:
#include<cstdio> #include<set> using namespace std; struct node{ int x,y; node(){ } node(int x,int y):x(x),y(y){ } bool operator <(const node &p)const{ return x<p.x||(x==p.x&&y<p.y); } }; set<node>ss; int main(){ node p[3]; for(int i=0;i<3;++i){ scanf("%d%d",&p[i].x,&p[i].y); } for(int i=0;i<3;++i) for(int j=i+1;j<3;++j){ node t; for(int k=0;k<3;++k) if(k!=i&&k!=j) t=p[k]; //ss.insert(t); int x=p[i].x-p[j].x; int y=p[i].y-p[j].y; ss.insert(node(t.x+x,t.y+y)); ss.insert(node(t.x-x,t.y-y)); } printf("%d\n",ss.size()); for(set<node>::iterator c=ss.begin();c!=ss.end();++c) printf("%d %d\n",c->x,c->y); }
如有不当之处欢迎指出!
CodeForces-749B的更多相关文章
- Codeforces 749B:Parallelogram is Back(计算几何)
http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...
- 【codeforces 749B】Parallelogram is Back
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- codeforces749B
Parallelogram is Back CodeForces - 749B 已知平行四边形的三个顶点,求第四个顶点可能的位置.Input输入有三行,每行包括两个整数x和y ( - 1000 ≤ x ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- jquery判断数据类型和相同字符串不相等
typeof object返回object对象数据类型 encodeURIComponent(str)//可把字符串作为URI 组件进行编码. 若str1和str2字符串数值相同,encodeURIC ...
- Log4j扩展使用--日志记录器Logger
OK,现在我们认真的研究下Logger的配置,进行相关配置扩展. Log4j有三个主要的组件:Loggers(记录器),Appenders(输出源)和Layouts(布局).其中,Logger负责记录 ...
- Composer - windows下安装方法
在windows下安装的方法 方法一:使用安装程序 这是将 Composer 安装在你机器上的最简单的方法. 下载并且运行 Composer-Setup.exe,它将安装最新版本的 Composer ...
- java 获取ip地址和网络接口
*/ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...
- nginx配置中root与alias的区别
nginx指定文件路径有两种方式root和alias,这两者的用法区别,使用方法总结了下,方便大家在应用过程中,快速响应.root与alias主要区别在于nginx如何解释location后面的uri ...
- 自动化安装DHCP配置脚本
DHCP配置脚本: #!/bin/sh NET=192.168.6.0 MASK=255.255.255.0 RANGE="192.168.6.50 192.168.6.100" ...
- 数据库备份shell脚本
法一: #!/bin/bash [ ! -d /server/backup ] && mkdir /server/backup mysqldump -u root -A -B > ...
- 【原创】@ResponseBody返回json数据时出现中文乱码
ι 版权声明:本文为博主原创文章,未经博主允许不得转载. 原因: Spring中解析字符串的转换器默认编码格式是ISO-8859-1 public class StringHttpMessageCon ...
- 不需要客户端插件PHP也能实现单点登录
分析CAS原理,构建PHP单点登录 单点登录(Single Sign On , 简称 SSO )是目前比较流行的服务于企业业务整合的解决方案之一, SSO 使得在多个应用系统中,用户 只需要登录一次就 ...
- python中的字符串格式化
Python中常见的字符串格式化方式包括两种:字符串插入(str%),format函数(str.format()) 1.字符串插入 字符串插入是设置字符串格式的简单方法,与C语言.Fortran语言差 ...