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.

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 test(s)
input
1 1
output
NO
input
5 5
output
YES
2 1
5 5
-2 4
input
5 10
output

YES
-10 4
-2 -2
1 2

题意 :就是告诉你一个直角三角形的两条直角边的长度,是否能找出这个三角形的三个点的坐标都是整数,并且任何一条边都不能与坐标轴平行,如果不满足输出NO

思路 : 这个题算是从头开始枚举,以原点为基准开始转,所以原点算一个点,然后从1开始枚举到a,因为不能与坐标轴平行的话,其中一个点到原点的那条边不能与坐标轴平行,所以只能作为坐标轴中的一条斜边来算(不是三角形的斜边),所以肯定比a小,然后枚举出整数来之后,再去求剩下的那个点就行了
#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的更多相关文章

  1. 【Codeforces Round #239 (Div. 1) A】Triangle

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最后的直角三角形可以通过平移,将直角顶点移动到坐标原点. 然后我们只要枚举另外两个点其中一个点的坐标就好了. x坐标的范围是[1.. ...

  2. Codeforces Round #239 (Div. 2)

    做了三个题,先贴一下代码...终于涨分了 A. Line to Cashier 水题 #include <iostream> #include <cstdio> #includ ...

  3. Codeforces Round #239 (Div. 1)C, 407C

    题目链接:http://codeforces.com/contest/407/problem/C 题目大意:给一个长度为n的数列,m次操作,每次操作由(li, ri, ki)描述,表示在数列li到ri ...

  4. Codeforces Round #239 (Div. 1) 二项式差分

    C - Curious Array 思路:对于区间[l, r]每个数加上C(i - l + k, k), 可以在l处+1, 在r+1处-1, 然后做k+1次求前缀和操作,然后就可以写啦. 然后逐层求前 ...

  5. Codeforces Round #239(Div. 2) 做后扯淡玩

    今天补了下 cf 239div2 顿时信心再度受挫 老子几乎已经木有时间了啊 坐着等死的命.哎!!! 到现在还只能做大众题,打铁都不行. 每次D题都是有思路敲错,尼玛不带这么坑爹的. 哎!不写了,写这 ...

  6. Codeforces Round #239 (Div. 1)

    B. Long Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  7. 【Codeforces Round #239 (Div. 1) B】 Long Path

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] DP,设f[i]表示第一次到i这个房间的时候传送的次数. f[1] = 0,f[2] = 2 考虑第i个位置的情况. 它肯定是从i- ...

  8. Codeforces Round #368 (Div. 2) C. Pythagorean Triples(数学)

    Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a ...

  9. 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 ...

随机推荐

  1. 浏览器是如何运行HTML的?

     什么是网页  网页(HTML page)是在浏览器(Browser)上运行并且可以与用户产生互动的应用程序.                            此图为浏览器运行HTML 这个想说 ...

  2. jsp实现计算器

    JavaBean package com.itheima.domain; import java.math.BigDecimal; public class BigDecimalDemo { priv ...

  3. h2database源码浅析:SQL语句的执行

    最近想好好了解一下数据库的原理,下载了h2database的源码,准备好好看看.此过程的一些想法,暂且记下来,权当做读码笔记吧! 为了调试准备的测试用例: @Test public void test ...

  4. git subtree

    语法:git subtree split -P <被裁减的目录> -b <分支> git subtree split -P SDK/CustomUI(需要裁减的) -b Cus ...

  5. Android屏幕保持唤醒状态

    我们程序偶尔会有需要屏幕一直或较长时间的保持唤醒状态,而用户的睡眠时间又设置的比较短.这时可能会对程序以及用户的使用造成一定的影响.在Android中有两种方法,可以让我们在我们需要保持唤醒的页面长时 ...

  6. POJ3368(RMQ)

    Frequent values Description You are given a sequence of n integers a1 , a2 , ... , an in non-decreas ...

  7. 暑假集训(3)第一弹 -----还是畅通工程(hdu1233)

    题意梗概:N(n<100)个村子想要富起来,自然就要先修路,不过到底还是没富起来,所以陷入了一个怪圈 :资金不足->修不起路->资金不足...... 为了实现走向全民小康社会,全面实 ...

  8. Walkthrough: Creating and Using a Dynamic Link Library (C++)

    Original Link: http://msdn.microsoft.com/zh-cn/library/ms235636.aspx Following content is only used ...

  9. html5 meta头部设置

    <meta name="viewport" content="height=[pixel_value | device-height], width=[pixel_ ...

  10. 如何使用ERStudio 生成comment

    在ER使用中,在生成sql过程中,如何批量生成字段描述,如何批量添加Owner,请看下文: 1.ER生成字段描述 2.ER生成描述添加Owner 使用的ER版本是8.0,英文版本,在操作过程中,有些配 ...