Codeforces Round #239 (Div. 2) C. Triangle
time limit per test:1 second
memory limit per test:256 megabytes
input:standard input
output:standard output
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.
The first line contains two integers a, b (1 ≤ a, b ≤ 1000), separated by a single space.
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.
1 1
NO
5 5
YES
2 1
5 5
-2 4
5 10
YES
-10 4
-2 -2
1 2
题意 :就是告诉你一个直角三角形的两条直角边的长度,是否能找出这个三角形的三个点的坐标都是整数,并且任何一条边都不能与坐标轴平行,如果不满足输出NO
#include <iostream>
#include <stdio.h>
#include <math.h> using namespace std; int main()
{
int a,b;
scanf("%d %d",&a,&b) ;
for(int i = ; i < a ; i++)
{
double t = sqrt(a*a-i*i);
if(t-(int)t==)
{
double ta = -*(b*t)/a;
double tb = (b*i)/a;
if(ta-(int)ta== && tb-(int)tb== && tb!=t)
{
printf("YES\n0 0\n%d %.0lf\n%.0lf %.0lf\n",i,t,ta,tb) ;
return ;
}
}
}
printf("NO\n") ;
return ;
}
Codeforces Round #239 (Div. 2) C. Triangle的更多相关文章
- 【Codeforces Round #239 (Div. 1) A】Triangle
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后的直角三角形可以通过平移,将直角顶点移动到坐标原点. 然后我们只要枚举另外两个点其中一个点的坐标就好了. x坐标的范围是[1.. ...
- Codeforces Round #239 (Div. 2)
做了三个题,先贴一下代码...终于涨分了 A. Line to Cashier 水题 #include <iostream> #include <cstdio> #includ ...
- Codeforces Round #239 (Div. 1)C, 407C
题目链接:http://codeforces.com/contest/407/problem/C 题目大意:给一个长度为n的数列,m次操作,每次操作由(li, ri, ki)描述,表示在数列li到ri ...
- Codeforces Round #239 (Div. 1) 二项式差分
C - Curious Array 思路:对于区间[l, r]每个数加上C(i - l + k, k), 可以在l处+1, 在r+1处-1, 然后做k+1次求前缀和操作,然后就可以写啦. 然后逐层求前 ...
- Codeforces Round #239(Div. 2) 做后扯淡玩
今天补了下 cf 239div2 顿时信心再度受挫 老子几乎已经木有时间了啊 坐着等死的命.哎!!! 到现在还只能做大众题,打铁都不行. 每次D题都是有思路敲错,尼玛不带这么坑爹的. 哎!不写了,写这 ...
- Codeforces Round #239 (Div. 1)
B. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- 【Codeforces Round #239 (Div. 1) B】 Long Path
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] DP,设f[i]表示第一次到i这个房间的时候传送的次数. f[1] = 0,f[2] = 2 考虑第i个位置的情况. 它肯定是从i- ...
- Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
随机推荐
- JavaScript高级程序设计(第三版)学习笔记22、24、25章
第22章,高级技巧 高级函数 安全的类型检测 typeof会出现无法预知的行为 instanceof在多个全局作用域中并不能正确工作 调用Object原生的toString方法,会返回[Object ...
- 最新版spark1.1.0集群安装配置
和分布式文件系统和NoSQL数据库相比而言,spark集群的安装配置还算是比较简单的: 很多教程提到要安装java和scala,但我发现spark最新版本是包含scala的,JRE采用linux内嵌的 ...
- Android带头像的用户注册页面
详细的图文可以到我的百度经验去查看:http://jingyan.baidu.com/article/cd4c2979eda109756e6e60de.html 首先是注册页面的布局: <?xm ...
- Metadata file not found - Data.Entity.Model
错误 3 正在编译转换: 未能找到元数据文件“F:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\Micr ...
- 备份BinLog并压缩 全备份
Rem Backup Mysql Binlog Rem Backup Yesterday and RAR Rem Backup every day 00:01 begin backup yesterd ...
- iOS-Reachability的使用
// 下载地址:http://pan.baidu.com/s/1gd5NNDD // 1. 添加Reachability.h和Reachibility.m文件到项目中 // 2. 添加System ...
- FreeMarker-Built-ins for numbers
http://freemarker.org/docs/ref_builtins_number.html#topic.extendedJavaDecimalFormat Page Contents ab ...
- JSP编程中常用的JavaScript技术(转载)
1.<tronMouseOver=this.style.backgroundColor=’#FFFFFF’ onMouseOut=this.style.backgroundColor=”> ...
- bzoj3208:花神的秒题计划I
思路:因为Q.S.B操作总和不超过100,因此怎么暴力怎么写....当然记忆化搜索还是要的 #include<cstdio> #include<iostream> #inclu ...
- iOS中的定时器 - NSTimer 使用方法
我的技术博客经常被流氓网站恶意爬取转载.请移步原文:http://www.cnblogs.com/hamhog/p/3556805.html,享受整齐的排版.有效的链接.正确的代码缩进.更好的阅读体验 ...