给定一个直角三角形的一边长度。问是否存在一个直角三角形,使得它满足有一边的长度是x
当x=1、2的时候是无解的,可以暴力打表看看。
注意到,相邻的两个数的平方的差值是奇数
x^2 - (x-1)^2 = 2*x-1
间隔为2的两个数的平方的差值是偶数
(x+1)^2 - (x-1)^2 = 4*x
这样就可以分类讨论了。
把n永远当成是指角边就OK
View Code
wx634d08b5232a4 ©著作权
给定一个直角三角形的一边长度。问是否存在一个直角三角形,使得它满足有一边的长度是x
当x=1、2的时候是无解的,可以暴力打表看看。
注意到,相邻的两个数的平方的差值是奇数
x^2 - (x-1)^2 = 2*x-1
间隔为2的两个数的平方的差值是偶数
(x+1)^2 - (x-1)^2 = 4*x
这样就可以分类讨论了。
把n永远当成是指角边就OK
View Code
构造函数和析构函数构造函数
第二天
C. Pythagorean Triplestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputKatya studies in a fifth grade. Recen
Brains Phot
文件系统对应类 System.IO1.DriveInfo : 有关驱动器信息的类主要方法:GetDrives 用于取得本计算机中所有驱动器信息对象2.File: 有关对文件整体操作及内容读写的类 整体操作: Cr
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M