迅雷后端笔试 素勾股数
/*迅雷后端笔试 素勾股数*/#include<stdio.h>
#include<math.h>
int gcd(int x, int y)
{
return (y>0) ? gcd(y, x%y) : x;
}
int main()
{
int N, n, m, num = 0;
scanf_s("%d", &N);
for (int n = 1; n <= sqrt(N - 1); n += 2)
{
for (int m = n + 2; n*n + m * m <= 2 * N; m += 2)
{
if (gcd(n, m) == 1)
num++;
}
}
printf("%d", num);
return 0;
}
#笔试题目##迅雷#