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 ...
随机推荐
- session的介绍与简单使用
cookie由浏览器带着,容易被篡改因为cookie很容易被篡改,所以cookie用来记住用户名,记住浏览历史等安全性要求不高的地方可以用sessin技术session技术将信息存入服务器,然后再给客 ...
- 【转】myeclipse 上安装 Maven3
[转]myeclipse 上安装 Maven3 环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Ma ...
- cookie管理中的一些细节,转的
1.domain表示的是cookie所在的域,默认为请求的地址,如网址为www.jb51.net/test/test.aspx,那么domain默认为www.jb51.net.而跨域访问,如域A为t1 ...
- VMware下LINUX的虚拟机增加磁盘空间
先关闭虚拟机电源,做如下设置:“ 虚拟机”--“虚拟机设置”--“磁盘”--“扩展” 可以随意添加你需要增到到的磁盘大小(如15Gb,表示磁盘总量,包含原来的磁盘容量); 再重启电源进入系统做如下步骤 ...
- sql 理解视图
可以看作是定义在sqlserver上的虚拟的表,本身并不存储数据,仅仅存储一个select语句和涉及的表的引用 通过视图,客户端不再需要知道底层表结构和其之间的关系,视图提供了一个统一访问数据的接口 ...
- struts2中<s:property>的用法
1,访问Action值栈中的普通属性: <s:property value="attrName"/> 2,访问Action值栈中的对象属性(要有get set方法): ...
- JS原型与原型链终极详解(转)
JavaScript原型及原型链详解 一. 普通对象与函数对象 JavaScript 中,万物皆对象!但对象也是有区别的.分为普通对象和函数对象,Object,Function 是JS自带的函数对象. ...
- Java标准输入输出流的重定向及恢复
在Java中输入输出数据一般(图形化界面例外)要用到标准输入输出流System.in和System.out,System.in,System.out默认指向控制台,但有时程序从文件中输入数据并将结果输 ...
- iOS数据库操作流程
SQLite最新的版本是3.0,使用之前应该先导入libsqlite3.0.dylib 1.导入流程 2.iOS中操作数据库的流程 打开数据库 准备SQL数据库 执行SQL数据库 语句完结 关闭数据库 ...
- 转载:【高并发简单解决方案 | 靠谱崔小拽 】redis队列缓存 + mysql 批量入库 + php离线整合
需求背景:有个调用统计日志存储和统计需求,要求存储到mysql中:存储数据高峰能达到日均千万,瓶颈在于直接入库并发太高,可能会把mysql干垮. 问题分析 思考:应用网站架构的衍化过程中,应用最新的框 ...