Content

一个矩形的顶点为 \((0,0)\),其对顶点为 \((x,y)\),现过 \((x,y)\) 作直线,分别交 \(x\) 轴和 \(y\) 轴于 \(A,B\) 两点,使得 \(\triangle OAB\) 为一个等腰直角三角形,求 \(A,B\) 点的坐标。(输出时 \(x\) 坐标小的先输出)

数据范围:\(-10^9\leqslant x,y\leqslant 10^9,x,y\neq 0\)。

Solution

这题是个数学题目,需要用到分类讨论。

这里先把草图给放上,方便大家理解——

当 \(x>0,y>0\),即 \((x,y)\) 在第一象限时,即如上图中 \(D\) 点所示。那么设我们过 \(D\) 点做的直线分别交 \(x,y\) 轴于 \(A_1,B_1\) 两点,并过 \(D\) 点做 \(DH_1\perp OA_1\)。则有 \(\angle DA_1O=45^\circ\)。所以 \(\triangle DH_1A_1\) 是一个等腰直角三角形,所以 \(H_1A_1=DH_1=|x|=x\)。同理,过 \(D\) 点做 \(DH_2\perp OB_1\),则有 \(\angle DB_1O=45^\circ\),所以 \(\triangle DH_2B_1\) 是一个等腰直角三角形,所以 \(B_1H_2=DH_2=|y|=y\)。所以 \(A_1\) 的横坐标为 \(OH_1+DH_1=x+y\),\(B_1\) 的纵坐标为 \(OH_2+B_1H_2=x+y\)。所以最终的结果就是 \(A_1(x+y,0),B_1(0,x+y)\)。

这里以第一象限的为例,其他的就请读者自己去推啦~

Code

#include <cstdio>
using namespace std; int main() {
int a, b;
scanf("%d%d", &a, &b);
if(a > 0 && b > 0) printf("0 %d %d 0", a + b, a + b);
else if(a < 0 && b > 0) printf("%d 0 0 %d", a - b, -a + b);
else if(a < 0 && b < 0) printf("%d 0 0 %d", a + b, a + b);
else if(a > 0 && b < 0) printf("0 %d %d 0", a - b, -a + b);
return 0;
}

CF336A Vasily the Bear and Triangle 题解的更多相关文章

  1. Codeforces Round #195 (Div. 2) A. Vasily the Bear and Triangle

    水题,注意数据范围即可 #include <iostream> #include <algorithm> #include <utility> using name ...

  2. codeforces A. Vasily the Bear and Triangle 解题报告

    题目链接:http://codeforces.com/problemset/problem/336/A 好简单的一条数学题,是8月9日的.比赛中没有做出来,今天看,从pupil变成Newbie了,那个 ...

  3. cf A. Vasily the Bear and Triangle

    http://codeforces.com/contest/336/problem/A #include <cstdio> #include <cstring> #includ ...

  4. codeforces 336D Vasily the Bear and Beautiful Strings(组合数学)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Vasily the Bear and Beautiful Strings Vas ...

  5. codeforces 336C Vasily the Bear and Sequence(贪心)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Vasily the Bear and Sequence Vasily the b ...

  6. C. Vasily the Bear and Sequence Codeforces 336C(枚举,思维)

    C. Vasily the Bear and Sequence time limit per test 1 second memory limit per test 256 megabytes inp ...

  7. ZOJ 4081 Little Sub and Pascal's Triangle 题解

    ZOJ 4081 Little Sub and Pascal's Triangle 题解 题意 求杨辉三角第n行(从1开始计数)有几个奇数. 考察的其实是杨辉--帕斯卡三角的性质,或者说Gould's ...

  8. Codeforces Round #195 (Div. 2) D题Vasily the Bear and Beautiful Strings

    这场CF,脑子乱死啊...C题,搞了很长时间,结束了,才想到怎么做.B题,没看,D题,今天看了一下,很不错的组合题. 如果n和m都挺多的时候 以下情况都是变为1,根据偶数个0,最后将会为1,奇数个0, ...

  9. codechef Sums in a Triangle题解

    Let's consider a triangle of numbers in which a number appears in the first line, two numbers appear ...

随机推荐

  1. 用idea生成javadoc在线文档

    1.点击需要生成文档的包 2.点击tools--->选择generate javaDoc /1选择输出目录 /2防止中文乱码建议加上: -encoding utf-8 -charset utf- ...

  2. 【Matrix-tree Theorem学习笔记】

    定义度数矩阵\(D(G)\): 定义邻接矩阵\(C(G)\): 定义\(Laplace\)矩阵\(A\) \( A(G) = D(G) - C(G) \) 记图\(G\)的所有生成树权值和为\(t(G ...

  3. Codeforces 840E - In a Trap(树分块+trie)

    Codeforces 题面传送门 & 洛谷题面传送门 一道非常精彩,同时也很经典的题目.和这场的 C 一样经典 首先看到这个数据范围先猜正解复杂度:\(n\) 级别大于 \(q\),所以大概是 ...

  4. REPuter注释叶绿体重复序列

    REPuter可注释叶绿体重复序列,包括4种类型,Forward(F), Reverse (R), Complement (C), Palindromic (P). REPuter 是可在线注释, 详 ...

  5. cd-hit 去除冗余序列

    最近一篇NG中使用到的软件,用来去除冗余的contigs,现简单记录. CD-HIT早先是一个蛋白聚类的软件,其主要的特定就是快!(ps:不是所有快的都是好的) 其去除冗余序列的大概思路就是: 首先对 ...

  6. datamash 命令行下的快速计算工具

    github地址:https://github.com/agordon/datamash

  7. SIG -MESH -1

    协议栈    node:成为蓝牙mesh网络中一员的设备被称为节点(Node). 蓝牙mesh规格定义了节点可能拥有的特性.具有这些特性中的一个或多个,即表示节点可以在网络中扮演相应的特殊角色.定义的 ...

  8. SpringBoot集成Kafka的实战用法大全

    本文是SpringBoot+Kafka的实战讲解,如果对kafka的架构原理还不了解的读者,建议先看一下<大白话kafka架构原理>.<秒懂kafka HA(高可用)>两篇文章 ...

  9. 运算符重载+日期类Date

    Hello,一只爱学习的鱼 大学学习C++运算符重载的时候,老师出了一道"运算符重载+类"的综合练习题,让我们来一起看看吧! 题目: 设计一个日期类Date,包括年.月.日等私有成 ...

  10. A Child's History of England.12

    Dunstan, Abbot of Glastonbury Abbey, was one of the most sagacious of these monks. He was an ingenio ...