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 ...
随机推荐
- [转载][jQuery] Cannot read property ‘msie’ of undefined错误的解决方法
参考 [jQuery] Cannot read property ‘msie’ of undefined错误的解决方法 ---------------------------------------- ...
- alert
先别着急测试,来猜测一下下面一行代码执行的结果 alert(alert(1234567)); 此刻,我自己还不是不太理解 我的分析是这样: alert() 是window下面的一个方法 alert(1 ...
- SQL Server(高级) 关键字的使用 二
二, 高级 关键字 -- 使用介绍 8,Top 的使用(Top子句返回记录的数目) select top number|percent column_name(s) from table_name 或 ...
- eclipse 好用的插件安装地址集合【持续更新】
1.PropertiesEditor (编辑properties文件的插件): http://propedit.sourceforge.jp/eclipse/updates/ 2.Aptana Stu ...
- Web应用程序安全必须重视八大问题
摘自:http://netsecurity.51cto.com/art/201402/428709.htm 对于任何一个项目,开始阶段对于交付安全的应用来说非常关键.适当的安全要求会导致正确的安全设计 ...
- Sencha Touch id 和 itemId
通过id获得组件: var view=Ext.getCmp('id'); 通过itemId获得组件: var view = ComponentQuery.query('view_xtype'), // ...
- Oracle笔记(三)单行函数
-函数 函数像一个黑盒子一样(看不到里边的构造),有参数返回值,可以为我们完成一定的功能. -单行 这种函数会对结果中的每一行计算一次,每行返回一个结果,单行概念区别于分组函数. 单行函数主要分为以下 ...
- ###STL学习--vector
点击查看Evernote原文. #@author: gr #@date: 2014-08-11 #@email: forgerui@gmail.com vector的相关问题.<stl学习> ...
- HTML5 Video与Audio 视频与音频
---- 视频Video对象 - 指定视频播放地址 <video width="320" height="240" controls="cont ...
- Json操作
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...