求助 30分 不知道哪里错了

P2141 [NOIP2014 普及组] 珠心算测验

@[shpp](/user/1304971)
by 11514zbs @ 2024-03-18 19:45:03


```cpp #include <bits/stdc++.h> int a, b, c[110], f[110], t, i, x, y, z, n, ans; int main() { scanf("%d", &n); for (int j = 1; j <= n; j++) { scanf("%d",&c[j]); f[j]=0; } for (int j = 1; j <= n; j++) { for (i = 1; i <= n; i++) { for (t = 1; t <= n; t++) { if (c[j] == c[i] + c[t]) { if ( j != i && i != t && j != t && f[j] == 0) { ans++; f[j] = 1; } } } } } printf("%d", ans); return 0; } ``` 求关×1 QwQ
by 11514zbs @ 2024-03-18 19:49:32


加一个判断去重操作,因为一个数可能是多组数的和,但只能算一个 (我30分就是这样的。。
by canwen2 @ 2024-03-31 19:36:04


|