当前位置:网站首页>FZU1669 Right-angled Triangle【毕达哥拉斯三元组】
FZU1669 Right-angled Triangle【毕达哥拉斯三元组】
2022-07-27 16:41:00 【51CTO】
题目链接:
http://acm.fzu.edu.cn/problem.php?pid=1669
题目大意:
求满足以a、b为直角边,c为斜边,并且满足a + b + c <= L的直角三角形的个数。
思路:
勾股定理,a、b、c也就是本原毕达哥拉斯三元组,则满足:
x = m^2 - n^2
y = 2*m*n
z = m^2 + n^2
其中m > n,且若m为奇数,则n为偶数,若m为偶数,则n为奇数。
枚举m、n,然后将三元组乘以i倍,保证 i * (x + y + z)在所给范围内(2 * m^2 + 2 * m*n <= L),
就可以求出所有满足条件的三元组。
AC代码:
边栏推荐
猜你喜欢

Error analysis of building Alibaba cloud +typera+picgo map bed

C语言案例:密码设置及登录> 明解getchar与scanf

Unity display Kinect depth data

Webmagic+selenium+chromedriver+jdbc grabs data vertically.

The first entry-level operation of kettle (reading excel, outputting Excel)

MySQL 02 initial experience

ES6学习笔记(1)——快速入门

Selenium自动化测试面试题全家桶

Win10 tips (1) -- transfer desktop location

VMware: set up SSH
随机推荐
换行问题双保险
Using vscode to build u-boot development environment
一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?
浅谈基本的网络基本故障和问题排查
Selenium自动化测试面试题全家桶
webservice的疑问
IDEA连接数据库时区问题,报红Server returns invalid timezone. Need to set ‘serverTimezone‘ property.
During the interface test, connect to the database and back up, restore and verify the data source
Latex use - control the display position of tables or graphics
图的遍历的定义以及深度优先搜索和广度优先搜索(二)
阿里云对象存储OSS的开通和使用
SSM integration
Webmagic+selenium+chromedriver+jdbc grabs data vertically.
Unity学习笔记(刚体-物理-碰撞器-触发器)
The go zero singleton service uses generics to simplify the registration of handler routes
ES6 learning notes (1) - quick start
SQL field type conversion
MongoDB学习笔记(1)——安装MongoDB及其相关配置
kettle8.2 安装及常见问题
SQL Server top keyword usage