# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22303 | Lazy Against The Machine (#40) | Unifying Values (KRIII5_UV) | C++14 | 13 ms | 3276 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
long long dat[10005];
long long presum[10005];
map<long long, vector<int>> mp;
constexpr int MOD = 1000000007;
int cnt[10005];
int main()
{
int n;
scanf("%d",&n);
for (int i = 1; i <= n; i++)
{
scanf("%lld",&dat[i]);
presum[i] = presum[i - 1] + dat[i];
mp[presum[i]].push_back(i);
}
int ans = 0;
if (presum[n] == 0)
{
int ans = 1;
for (int i = 1; i < mp[0].size(); i++)
{
ans = (ans << 1) % MOD;
}
printf("%d\n", (ans + MOD - 1) % MOD);
return 0;
}
for (int i = 1; i <= n; i++)
{
if (presum[i] == 0) continue;
if (presum[n] % presum[i]) continue;
long long f = presum[n] / presum[i];
if (f <= 1 || f > n - i + 1) continue;
bool wrong = false;
for (int j = 2; j <= f; j++)
{
if (mp.count(presum[i] * j) == 0)
{
wrong = true;
break;
}
}
if (wrong) continue;
int last = 2;
cnt[1] = 1;
for (int j = 2; j < n; j++)
{
if (presum[j] % presum[i]) continue;
long long x = presum[j] / presum[i];
if (x > last || x >= f || x == 1) continue;
if (x == last)
{
++last;
cnt[x] = cnt[x - 1];
}
else cnt[x] = (cnt[x] + cnt[x - 1]) % MOD;
}
if (last == f) ans = (ans + cnt[f - 1]) % MOD;
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |