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 ...
随机推荐
- synchronized内存可见性理解
一.背景 最近在看<Java并发编程实战>这本书,看到共享变量的可见性,其中说到"加锁的含义不仅仅局限于互斥行为,还包括内存可见性". 我对于内存可见性第一反应是vol ...
- JS实现倒计时
HTML部分: <div class="div"> <div id="div"> </div> </div> C ...
- java —— equals 与 ==
equals 众所周知,java 中的所有的类都继承自 Object 这个超类 ,他就是Java所有类的父类或祖先类,Object类里面有一个equals方法,并且提供了默认的实现,如下所示. pub ...
- MongoDB 基本操作学习笔记
// 查看所有数据库 show dbs // amdin 0.000GB // local 0.000GB // 使用数据库 use admin // switched to db admin // ...
- node-glob的*匹配
目录结构 src/js/libs/app.js src/js/index.js 测试脚本 var glob = require('glob') glob('', {}, function (err, ...
- rapid framework开发系列(一)
定义:web项目脚手架 rapid-framework是一个以spring为核心的项目脚手架(或者称为胶水框架),框架将各个零散的框架(struts,strust2,springmvc,hiberna ...
- 记录下直接在git里读取出差异并打包的代码
一行命令: git diff --name-only HEAD commit_id | xargs tar -zcvf diff_head.tar.gz 这里的HEAD可以理解为最新的版本 HEAD本 ...
- python小白之路
阅读目录: 第一章:计算机基础 计算机硬件.操作系统.网络协议 第二章:python基础 初识python.常量变量.输入输出运算符.条件与循环语句.数字与字符串.列表与字典.元组与集合.阶段小测.字 ...
- C# ListBox 每行显示颜色设置
使用ListBox时,每行显示不同的颜色 1.把AllowHtmlDraw属性设置为True 2.直接在Add或者AddRange里写标签 代码里用的是DEV插件里的ListBox,使用原生的也是一样 ...
- 一步一步从原理跟我学邮件收取及发送 11.完整的发送示例与go语言
经过了这个系列的前几篇文章的学习,现在要写出一个完整的 smtp 邮件发送过程简直易如反掌. 例如我们可以轻松地写出以下的纯 C 语言代码(引用的其他C语言文件请看文末的 github 地址): ...