codeforces 459 A. Pashmak and Garden 解题报告
题目链接:http://codeforces.com/problemset/problem/459/A
题目意思:给出两个点的坐标你,问能否判断是一个正方形,能则输出剩下两点的坐标,不能就输出 -1。
这题更傻了,在考虑对角线的两点时,少考虑了一种情况:两个点分属不同象限:这时需要用到绝对值函数 abs !
最近集训不知道是不是搞傻左,反正CF的题目打了几场,结果都很惨,有一点点恐惧感,怕跌回以前不堪的rating。唉~~~继续努力吧!!!
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std; int main()
{
int x1, y1, x2, y2;
while (scanf("%d%d%d%d", &x1, &y1, &x2, &y2) != EOF)
{
// 两点平行,绝对有解
if (x1 == x2 && y1 != y2) // x 坐标相同
{
if (x1 + (y1-y2) >= - && x1 + (y1-y2) <= ) // 这是为了严谨起见,可能会超出给定范围
printf("%d %d %d %d\n", x1 + (y1-y2), y1, x2 + (y1-y2), y2);
else
printf("%d %d %d %d\n", x1 + (y2-y1), y1, x2 + (y2-y1), y2);
}
else if (y1 == y2 && x1 != x2) // y 坐标相同
{
if ((x1-x2) + y1 >= - && (x1-x2) + y1 <= )
printf("%d %d %d %d\n", x1, (x1-x2) + y1, x2, (x1-x2) + y2);
else
printf("%d %d %d %d\n", x1, (x2-x1) + y1, x2, (x2-x1) + y2);
}
// 对角线情况不一定有解
else if (abs(x1 - x2) == abs(y1 - y2)) // 对角线
{
printf("%d %d %d %d\n", x1, y2, x2, y1);
}
else
{
printf("-1\n");
}
}
return ;
}
codeforces 459 A. Pashmak and Garden 解题报告的更多相关文章
- codeforces 459 B.Pashmak and Flowers 解题报告
题目链接:http://codeforces.com/problemset/problem/459/B 题目意思:有 n 朵 flowers,每朵flower有相应的 beauty,求出最大的beau ...
- codeforces 459C Pashmak and Buses 解题报告
题目链接:http://codeforces.com/problemset/problem/459/C 题目意思:有 n 个 students,k 辆 buses.问是否能对 n 个students安 ...
- codeforces C1. The Great Julya Calendar 解题报告
题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...
- codeforces B. Eugeny and Play List 解题报告
题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...
- codeforces 433C. Ryouko's Memory Note 解题报告
题目链接:http://codeforces.com/problemset/problem/433/C 题目意思:一本书有 n 页,每页的编号依次从 1 到 n 编排.如果从页 x 翻到页 y,那么| ...
- codeforces 459 E. Pashmak and Graph(dp)
题目链接:http://codeforces.com/contest/459/problem/E 题意:给出m条边n个点每条边都有权值问如果两边能够相连的条件是边权值是严格递增的话,最长能接几条边. ...
- codeforces 459 D. Pashmak and Parmida's problem(思维+线段树)
题目链接:http://codeforces.com/contest/459/problem/D 题意:给出数组a,定义f(l,r,x)为a[]的下标l到r之间,等于x的元素数.i和j符合f(1,i, ...
- codeforces 459 C. Pashmak and Buses(思维)
题目链接:http://codeforces.com/problemset/problem/459/C 题意:有n个人,k辆车,d天要求没有两个人在d天都坐在一起.输出坐的方法. 题解:这题很有意思, ...
- codeforces 556B. Case of Fake Numbers 解题报告
题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每 ...
随机推荐
- poj 3461 Oulipo,裸kmp
传送门 Oulipo Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 32373 Accepted: 13093 Desc ...
- 标准C程序设计七---07
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...
- Gdb学习笔记1
其实,从很早就开始接触gdb程序,gdb调试程序伴我成长,现在对其用法记录以下: 当程序的运行结果和预期结果不一致,或者程序出现运行错误时,gdb就可以派上大用处了.调试的基本过程是: -> ...
- FastDFS上传/下载过程[转载-经典图列]
FastDFS上传/下载过程: 首先客户端 client 发起对 FastDFS 的文件传输动作,是通过连接到某一台 Tracker Server 的指定端口来实现的,Tracker Server 根 ...
- CSS 选择器语法参考手册
转自:http://www.w3school.com.cn/cssref/css_selectors.asp CSS3 选择器 在 CSS 中,选择器是一种模式,用于选择需要添加样式的元素. &quo ...
- HDU - 5584 LCM Walk (数论 GCD)
A frog has just learned some number theory, and can't wait to show his ability to his girlfriend. No ...
- Codeforces Gym 100286I iSharp 模拟
原题地址:http://codeforces.com/gym/100286/attachments/download/2013/20082009-acmicpc-northeastern-europe ...
- android开发教程之使用线程实现视图平滑滚动示例 改
package com.melonsapp.messenger.ui.popupuser; import android.os.Handler; import android.view.View; i ...
- Action Bar详解(二)
在Android3.0之后,Google对UI导航设计上进行了一系列的改革,其中有一个非常好用的新功能就是引入的ActionBar,他用于取代3.0之前的标题栏,并提供更为丰富的导航效果. 一.添加A ...
- php-cpp用来开发php的拓展
官网: http://www.php-cpp.com/documentation/install, 找时间要学一下.