1925. 统计平方和三元组的数目
题目链接:1925. 统计平方和三元组的数目
代码如下:
cpp
class Solution {
public:
int countTriples(int n) {
int res = 0;
for (int a = 1;a < n;a++) {
for (int b = 1;b < n;b++) {
int x = a * a + b * b;
int c = static_cast<int>(sqrt(x));
if (c <= n && c * c == x) {
res++;
}
}
}
return res;
}
};