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 ...
随机推荐
- java 表现层:jsp、freemarker、velocity
在java领域,表现层技术主要有三种:jsp.freemarker.velocity. jsp是大家最熟悉的技术 优点: 1.功能强大,可以写java代码 2.支持jsp标签(jsp tag) 3.支 ...
- JS前端验证代码
手机号码正则表达式验证: function checkPhone(){ var phone = document.getElementById('phone').value; if(!(/^1[345 ...
- SQLServer2008修改sa密码的方法与SQL server 2008数据库的备份与还原
sa密码的修改转载自:http://blog.csdn.net/templar1000/article/details/20211191 SQL server 2008数据库的备份与还原转自 :htt ...
- Chrome浏览器调试Android的Webview
chrome://inspect Android:4.4+ Chrome 30+ 首次使用需要FQ
- datatables里面的search怎么去掉?
今天使用datatables插件的时候,由于需求是把自带的search去掉,并且给输入框加上placeholder="Search",使其看起来更简洁美观,于是乎简单粗暴的把代码改 ...
- Spring源码情操陶冶-PropertyPlaceholderBeanDefinitionParser注解配置解析器
本文针对spring配置的context:property-placeholder作下简单的分析,承接前文Spring源码情操陶冶-自定义节点的解析 spring配置文件应用 <context: ...
- bzoj 3597: [Scoi2014]方伯伯运椰子 [01分数规划 消圈定理 spfa负环]
3597: [Scoi2014]方伯伯运椰子 题意: from mhy12345 给你一个满流网络,对于每一条边,压缩容量1 需要费用ai,扩展容量1 需要bi, 当前容量上限ci,每单位通过该边花费 ...
- bzoj 2655: calc [容斥原理 伯努利数]
2655: calc 题意:长n的序列,每个数\(a_i \in [1,A]\),求所有满足\(a_i\)互不相同的序列的\(\prod_i a_i\)的和 clj的题 一下子想到容斥,一开始从普通容 ...
- [Sdoi2017]序列计数 [矩阵快速幂]
[Sdoi2017]序列计数 题意:长为\(n \le 10^9\)由不超过\(m \le 2 \cdot 10^7\)的正整数构成的和为\(t\le 100\)的倍数且至少有一个质数的序列个数 总- ...
- BZOJ 3781: 小B的询问 [莫队]
求区间每种颜色出现次数平方和 写裸题练手 #include <iostream> #include <cstdio> #include <algorithm> #i ...