给定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的更多相关文章

  1. Codeforces 749B:Parallelogram is Back(计算几何)

    http://codeforces.com/problemset/problem/749/B 题意:已知平行四边形三个顶点,求另外一个顶点可能的位置. 思路:用向量来做. #include <c ...

  2. 【codeforces 749B】Parallelogram is Back

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. codeforces749B

    Parallelogram is Back CodeForces - 749B 已知平行四边形的三个顶点,求第四个顶点可能的位置.Input输入有三行,每行包括两个整数x和y ( - 1000 ≤ x ...

  4. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  5. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  6. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  7. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  8. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  9. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  10. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. Python 正则表达式 (python网络爬虫)

    昨天 2018 年 01 月 31 日,农历腊月十五日.20:00 左右,152 年一遇的月全食.血月.蓝月将今晚呈现空中,虽然没有看到蓝月亮,血月.月全食也是勉强可以了,还是可以想像一下一瓶蓝月亮洗 ...

  2. tomcat监控(二)

    标签: linux 笔者Q:972581034 交流群:605799367.有任何疑问可与笔者或加群交流 这里介绍二种监控Tomcat的方法 使用windows版本的jdk监控 使用zabbix监控 ...

  3. OpenStack云平台网络模式及其工作机制

    转自:http://openstack.csdn.net/content.html?arcid=2808381 OpenStack云平台网络模式及其工作机制 网络,是OpenStack的部署中最容易出 ...

  4. Date对象和正则对象

    1.Date对象 创建 var date1 = new Date(); var date2 = new Date(12983798123);//填一个毫秒值,应该是距离1970年1月1日.....多少 ...

  5. 一个特殊的List去重问题的解决方案

    原创作品,可以转载,但是请标注出处地址:http://www.cnblogs.com/V1haoge/p/7039842.html 场景描述:公司新活动,需要在活动页面显示指定利率的四种投资项目,并且 ...

  6. c语言中的register int

    register int a=1; 明确声明必须要把变量存放在寄存器中,直到变量消失. 一般是默认register,大多数的情况下是不用写register

  7. 剑指offer得意之作——顺时针打印矩阵

    题目: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3 ...

  8. gradle一个已删除的项目找不到

    排查了已有模块未果,到.idea目录中找到了gradle.xml文件,发现其中externalProjectPath指向的正是报错的那个已删除项目,改之,刷gradle,解决.

  9. pycharm导入模块的时候遇到的两个错误

    1.from 包 import AES import后面一定是一个空格!!!!! 2.包的导入 上面多了一层报错 错误的原因是最外层多了一个pythonProject目录.改成下面的ok. 原因大佬这 ...

  10. SQL Server 文件操作

    在master数据库中,SQL Server提供系统扩展的存储过程,其中有一些存储过程的命名以xp_开头,用于处理操作系统的文件. 一,判断文件是否存在 存储过程sys.xp_fileexist 用于 ...