博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
codeforces C. Triangle
阅读量:4703 次
发布时间:2019-06-10

本文共 2133 字,大约阅读时间需要 7 分钟。

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.

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
YES2 15 5-2 4
input
5 10
output
YES-10 4-2 -21 2
 
 
 
#include "stdio.h"#include "string.h"#include "math.h"#include "vector"using namespace std;struct node{    int x,y;};vector
a[1005];bool change(int x1,int y1,int x2,int y2){ bool flag = true; if (-x1*x2+y1*y2==0 && y1!=y2) { printf("YES\n%d %d\n%d %d\n%d %d\n",0,0,-x1,y1,x2,y2); } else if(-x1*y2+y1*x2==0 && y1!=x2) { printf("YES\n%d %d\n%d %d\n%d %d\n",0,0,-x1,y1,y2,x2); } else if(-y1*x2+x1*y2==0 && x1!=y2) { printf("YES\n%d %d\n%d %d\n%d %d\n",0,0,-y1,x1,x2,y2); } else if(-y1*y2+x1*x2==0 && x1!=x2) { printf("YES\n%d %d\n%d %d\n%d %d\n",0,0,-y1,x1,y2,x2); } else flag = false; return flag;}int main(){ int i,j; int x,y; int ans,num; node cur; for(i=1; i<=1000; ++i) { for(j=i; j<=1000; ++j) { ans = (int)sqrt(i*i+j*j); if(ans > 1000) continue; if(ans*ans==i*i+j*j) { cur.x = i; cur.y = j; a[ans].push_back(cur); } } } bool flag = false; scanf("%d %d",&x,&y); for(i=0; i

转载于:https://www.cnblogs.com/ruo-yu/p/4411982.html

你可能感兴趣的文章
zTree async 动态参数处理
查看>>
Oracle学习之常见错误整理
查看>>
数据库插入数据乱码问题
查看>>
altium annotate 选项设置 complete existing packages
查看>>
【模式识别与机器学习】——SVM举例
查看>>
【转】IT名企面试:微软笔试题(1)
查看>>
IO流入门-第十章-DataInputStream_DataOutputStream
查看>>
DRF的分页
查看>>
Mysql 模糊匹配(字符串str中是否包含子字符串substr)
查看>>
python:open/文件操作
查看>>
流程控制 Day06
查看>>
Linux下安装Tomcat
查看>>
windows live writer 2012 0x80070643
查看>>
tomcat 和MySQL的安装
查看>>
git常用操作
查看>>
京东SSO单点登陆实现分析
查看>>
u-boot启动第一阶段
查看>>
MySQL批量SQL插入性能优化
查看>>
定义列属性:null,default,PK,auto_increment
查看>>
用户画像展示
查看>>