codeforces1462D
#include <cstdio>
#include <cstring>const int maxn = 3e3 + 5;int a[maxn], pre[maxn];int main () {int T, n;scanf ("%d", &T);while (T--) {scanf ("%d", &n);for (int i = 0; i < n; ++i) {scanf ("%d", &a[i]);}memset (pre, 0, sizeof pre);pre[0] = a[0];for (int i = 1; i < n; i++) {pre[i] = pre[i - 1] + a[i];}int ans = 0;for (int i = 0; i < n; i++) {int t = 0;bool flag = false;for (int j = 0; j < n; j++) {t = t + a[j];ans++;if (t == pre[i]) {t = 0;ans--;if (j == n - 1) flag = true;} else if (t > pre[i]) break;}if (flag) break;else ans = 0;}printf ("%dn", ans);}return 0;
}
本文发布于:2024-02-04 11:44:24,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170706409755262.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |