# 请问一共可以有多少种取木棍的方案

目前有一个长度为 n 的木棍，当做直角三角形的斜边。A,B,C要从许多整数长度的木棍中选出三根，分别长为 a, b, c。 现在，蒜头君和花椰妹的木棍组成一条直角边长度为 a + b，白菜君组成另外一条直角边 c，并且要求 a + b ≤ c。请问一共可以有多少种取木棍的方案。 提示：a = 3, b = 4 与 a = 4, b = 3 算作同一种方案。

以下程序实现了这一功能，请你填补空白处内容：

```cpp
#include <stdio.h>
int main()
{
    int n;
    int cnt = 0;
    scanf("%d", &n);
    for (int a = 1; a < n; a++)
        _______________;
    printf("一共有%d种方案", cnt);
    return 0;
}
```

## template

```cpp
#include <stdio.h>
int main()
{
    int n;
    int cnt = 0;
    scanf("%d", &n);
    for (int a = 1; a < n; a++)
        for (int b = a; b < n - a; b++)
            for (int c = 1; c < n; c++)
            {
                if ((a + b) * (a + b) + c * c == n * n)
                {
                    printf("a=%d b=%d c=%d\n", a, b, c);
                    cnt++;
                }
            }
    printf("一共有%d种方案", cnt);
    return 0;
}
```

## 答案

```cpp
for (int b = a; b < n - a; b++)
	for (int c = 1; c < n; c++)
	{
		if ((a + b) * (a + b) + c * c == n * n)
		{
			printf("a=%d b=%d c=%d\n", a, b, c);
			cnt++;
		}
	}
```

## 选项

### A

```cpp
for (int b = a; b < n - a; b++)
	for (int c = 1; c < n; c++)
	{
		if ((a + b) * (a + b) + c * c >= n * n)
		{
			printf("a=%d b=%d c=%d\n", a, b, c);
			cnt++;
		}
	}
```

### B

```cpp
for (int b = a; b < n - a; b++)
	for (int c = 1; c < n; c++)
	{
		if ((a + b) * (a + b) + c * c <= n * n)
		{
			printf("a=%d b=%d c=%d\n", a, b, c);
			cnt++;
		}
	}
```

### C

```cpp
for (int b = a; b < n - a; b++)
	for (int c = 1; c < n; c++)
	{
		if ((a + b) * (a + b) + c * c > n * n)
		{
			printf("a=%d b=%d c=%d\n", a, b, c);
			cnt++;
		}
	}
```