社区讨论
96pts,12tle 求调
P3131[USACO16JAN] Subsequences Summing to Sevens S参与者 3已保存回复 6
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 6 条
- 当前快照
- 1 份
- 快照标识符
- @mhjazrdv
- 此快照首次捕获于
- 2025/11/03 23:37 4 个月前
- 此快照最后确认于
- 2025/11/03 23:37 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, a, f[50005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a;
f[i] = f[i - 1] + a;
}
for (int t = n; t >= 1; t--) {
for (int i = 1; i <= n - t + 1; i++) {
int j = i + t - 1;
if ((f[j] - f[i - 1]) % 7 == 0) {
cout << t;
return 0;
}
}
}
cout << 0;
return 0;
}
回复
共 6 条回复,欢迎继续交流。
正在加载回复...