CodeForces - 407A
| Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u | 
Description
There is a right triangle with legs of length a and b. Your task is to determine whether it is possible to locate the triangle on the plane in such a way that none of its sides is parallel to the coordinate axes. All the vertices must have integer coordinates. If there exists such a location, you have to output the appropriate coordinates of vertices.
Input
The first line contains two integers a, b (1 ≤ a, b ≤ 1000), separated by a single space.
Output
In the first line print either "YES" or "NO" (without the quotes) depending on whether the required location exists. If it does, print in the next three lines three pairs of integers — the coordinates of the triangle vertices, one pair per line. The coordinates must be integers, not exceeding 109 in their absolute value.
Sample Input
1 1
NO
5 5
YES
2 1
5 5
-2 4
5 10
YES
-10 4
-2 -2
1 2
Source
首先要求在平面内找到一个直角三角形,两个边
长分别为a,b,并且三条边都不得与二维坐标轴的 
平行,且点都在整数点上,首先这个三角形若是
存在的话,那么它肯定可以在这个平面上平移的
,那么我们把它给移到一二象限,然后一个点固
定在(0,0)点,这样另外两个点看一下 a,b,的范
围,那么另外两个点无非在 一二两个象限内以
(0,0)为端点的 边长为1000的正方形内,在这两
个正方形内 枚举出所有符合的点,分在两个容器
内,然后在枚举两个点 与(0,0)点是否可以组成
直角三角形,是否与坐标轴平行
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
void solve()
{int T,t,n,m,i,j,k,a,b,a1,a2=,b1,b2;
scanf("%d%d",&a,&b);
for(a1=;a1<a;a1++)
{ a2=sqrt(a*a-a1*a1);
if(a*a==a1*a1+a2*a2)
{ b1=a1*b/a;
b2=a2*b/a;
if(b*b==b1*b1+b2*b2 && a2!=b1)
{ printf("YES\n");
printf("0 0\n");
printf("%d %d\n",a1,a2);
printf("%d %d\n",-b2,b1);
return;
}
}
}
printf("NO\n");
}
int main()
{ solve();
}
CodeForces - 407A的更多相关文章
- 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 ... 
- CodeForces - 696B Puzzles
		http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ... 
- CodeForces - 148D Bag of mice
		http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ... 
随机推荐
- Vijos1889 天真的因数分解
			描述 小岛: 什么叫做因数分解呢?doc : 就是将给定的正整数n, 分解为若干个素数连乘的形式.小岛: 那比如说 n=12 呢?doc : 那么就是 12 = 2 X 2 X 3 呀.小岛: 呜呜, ... 
- Tomcat Server Configuration Automation Reinforcement
			目录 . 引言 . 黑客针对WEB Server会有那些攻击面 . 针对Tomcat Server可以做的安全加固 . Managing Security Realms with JMX . 实现对T ... 
- workon在zsh中不起作用
			先装了workon,然后装了zsh,发现在zsh里不起作用 翻了一下网上没有解答,就看了看bashrc文件,发现一句 source /usr/local/bin/virtualenvwrapper.s ... 
- mq安装参考
			CentOS 6.2 64bit 安装erlang及RabbitMQ Server 1.操作系统环境(CentOS 6.2 64bit) [root@leekwen ~]# cat /etc/issu ... 
- Hbase Shell常用命令
			hbase shell常用的操作命令有create,describe,disable,drop,list,scan,put,get,delete,deleteall,count,status等,通过h ... 
- C++中debug和release的区别 . 转载
			vc中debug和release的不同 收藏 在使用VC开发软件的过程中,正当要享受那种兴奋的时候突然发现:release与debug运行结果不一致,甚至出错,而release又不方便调试,真的是当 ... 
- --hdu 2124 Repair the Wall(贪心)
			题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2124 Ac code : #include<stdio.h> #include<st ... 
- Entity Framework 简单增删改操作
			前言 在 Entity Framework 简单查询操作 中主要是学习了在Entity Framework中的几种不同模式的查询操作,现在主要来学习一下简单的增加.删除.修改操作. 增加 在EF中添加 ... 
- dedecms删除没有文章的标签
			要批量的删除织梦TAG标签,那我们就只能在数据库里做修改了. 登录数据库,在数据库里执行以下SQL语句: delete FROM dede_tagindex where typeid not in ( ... 
- NGUI之UICamera控制触摸,鼠标事件
			http://blog.csdn.net/onerain88/article/details/18963539 . UICamera 功能介绍 主要包括UI事件的监听,分发,覆盖范围为此Camera渲 ... 
