0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-13 08:58:46 +00:00

P3131 [USACO16JAN] Subsequences Summing to Sevens S

R40246968
This commit is contained in:
Baoshuo Ren 2020-10-21 21:27:03 +08:00 committed by Baoshuo Ren
parent 204eb6c70a
commit 9ee5e67514
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

24
problem/P3131/P3131.cpp Normal file
View File

@ -0,0 +1,24 @@
#include <bits/stdc++.h>
using namespace std;
long long a[50005];
int main() {
int n, k;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> k;
a[i] = a[i - 1] + k;
}
for (int i = n; i > 0; i--) {
for (int j = 1; j + i <= n; j++) {
if ((a[i + j] - a[j]) % 7 == 0) {
cout << i << endl;
return 0;
}
}
}
cout << 0 << endl;
return 0;
}