cf 304A Pythagorean Theorem II
来源:互联网 发布:天猫和淘宝是什么关系 编辑:程序博客网 时间:2024/05/17 01:12
昨天训练赛的一个题目,看到以后直接谢了一发,然后wa了,加上了LL就可以过了,直接暴力就可以
双重循环
In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states:
In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle).
The theorem can be written as an equation relating the lengths of the sides a, b and c, often called the Pythagorean equation:
where c represents the length of the hypotenuse, and a and b represent the lengths of the other two sides.
Given n, your task is to count how many right-angled triangles with side-lengths a, b and c that satisfied an inequality 1 ≤ a ≤ b ≤ c ≤ n.
#include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorithm>#include <vector>#include <map>#include <math.h>#include <stack>#define LL long longusing namespace std;const int INF = 0x3f3f3f3f;int dir[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};int main(){ int cur = 0; int m; scanf("%d%d",&m); for(int i = 1;i <= m;i++) { for(int j = i;j <= m;j++) { if((LL)sqrt(i*i + j*j)*(LL)sqrt(i*i + j*j) == (LL)(i*i + j*j) && (sqrt(i*i + j*j) <= m)) cur++; } } cout<<cur<<endl; return 0;}
- cf 304A Pythagorean Theorem II
- CF 304A(Pythagorean Theorem II-n内勾股数)
- A. Pythagorean Theorem II
- A. Pythagorean Theorem II
- coderforce 304a - Pythagorean Theorem II
- codeforces 304A. Pythagorean Theorem II
- CodeForces 304A Pythagorean Theorem II
- CodeForces 304A Pythagorean Theorem II 【基础】【暴力】
- Pythagorean Theorem II
- Pythagorean Theorem II
- A. Pythagorean Theorem II(血的教训)
- codeforces 183(div2) A. Pythagorean Theorem II 枚举+二分查找
- Problem F Codeforces Round #183 (Div. 2) A. Pythagorean Theorem II
- <cf>Hexadecimal's theorem
- 勾股定理(Pythagorean Triples,cf 707C)
- Pythagorean Triples CF #368 div2 C
- A. Hexadecimal's theorem
- CF#368 C. Pythagorean Triples (数学/推导公式)
- pwnabe之cmd1
- JAVA学习划重点第一部分
- 基本数据类型
- strstr函数
- 51nod 1190 最小公倍数之和V2
- cf 304A Pythagorean Theorem II
- Swift 路由机制设计
- 我眼中的ASP.NET Core之微服务
- Python 实现 Discuz论坛附件下载权限绕过漏洞
- ReactiveCocoa源码解析(四) Signal中的静态属性静态方法以及面向协议扩展
- HDU-2669 拓展欧几里得
- 公司员工考勤系统Java代码
- Caffe3——ImageNet数据集创建lmdb类型的数据
- hdu—3342 Legal or Not 拓扑图的搜索