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. js动态生成按钮,页面用DIV简单布局

    今天朋友让我忙帮给写个页面,由于时间紧破,所以没有完善,暂时先贴出来,以后有时间了在做修改 <!DOCTYPE html><html><head><title ...

  2. HTTP层 —— 响应

    1.创建响应 字符串&数组 所有路由和控制器都会返回一个被发送到用户浏览器的响应,Laravel 提供了多种不同的方式来返回响应,最基本的响应就是从路由或控制器返回一个简单的字符串,框架会将这 ...

  3. js中的null与undefined

    null undefined

  4. 20160509-hibernate--继承映射

    继承映射 对象模型(Java类结构) 一个类继承体系一张表(subclass)(表结构) 1.一个类继承体系一张表(subclass)(映射文件) <class name="Emplo ...

  5. ClassLoader和Reflect

    什么情况下使用ClassLoader来加载类?其实这个问题应该问,什么时候使用import来加载类,不能使用import的,就只能使用ClassLoader了. 使用import的条件: 1.必须是存 ...

  6. SQLite 入门教程(一)基本控制台(终端)命令

    一.基本简介 SQLite 是一个自持的(self-contained).无服务器的.零配置的.事务型的关系型数据库引擎.因为他很小,所以也可以作为嵌入式数据库内建在你的应用程序中.SQLite 被应 ...

  7. Webbrowers控件的小技巧

    我最近接触webbrowers 这个控件比较多,感觉用起来比较顺手吧.可以做很多操作. 貌似很多网络模拟有时候都内置这个控件或者类似的控件,但这样子速度就不能跟那些单纯用API 构建数据包比了. 我一 ...

  8. Json 映射 的使用 及 JS 数组的使用

    Json 映射的使用: var nameMap = { 'A': 'A1', 'B': 'B1', 'B': 'B1' }; var selectedName='A'; if (nameMap[sel ...

  9. SQLite cans and can'ts

    SQLite 能做的 和 不能做的 1.SQLite_open/SQLite_open_v2

  10. STL简介

    由于不同书籍和翻译问题对STL中的术语可能有差别本文采用侯杰<STL源码剖析>中的术语 STL的组件 包含6个组件,分别为容器.算法.迭代器.仿函数(函数对象).配接器(适配器).配置器( ...