mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-24 03:31:59 +00:00
P3131 [USACO16JAN] Subsequences Summing to Sevens S
R40246968
This commit is contained in:
parent
204eb6c70a
commit
9ee5e67514
24
problem/P3131/P3131.cpp
Normal file
24
problem/P3131/P3131.cpp
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user