# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140145 | rdd6584 | Unifying Values (KRIII5_UV) | C++14 | 361 ms | 764 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 <cstdio>
#include <algorithm>
#include <memory.h>
#include <iostream>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
ll vec[10000];
int dp[10001];
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> vec[i];
if (i) vec[i] += vec[i - 1];
}
ll ans = 0;
for (int i = 0; i < n - 1; i++) {
if (!vec[i] || vec[n - 1] % vec[i]) continue;
ll t = vec[n - 1] / vec[i];
if (vec[i] > 0 && vec[n - 1] < 0 || vec[i] < 0 && vec[n - 1] > 0) continue;
if (t < 2 || t > 10000) continue;
memset(dp, 0, sizeof(dp));
dp[1] = 1;
for (int j = i + 1; j < n - 1; j++) {
if (!vec[j] || vec[j] % vec[i]) continue;
ll t = vec[j] / vec[i];
if (t >= 2 && t <= 10000)
dp[t] = (dp[t] + dp[t - 1]) % MOD;
}
ans = (ans + dp[t - 1]) % MOD;
}
if (vec[n - 1] == 0) {
ll sum = 1;
for (int i = 0; i < n - 1; i++)
if (vec[i] == 0)
sum = (sum << 1) % MOD;
sum += MOD - 1;
ans = (ans + sum) % MOD;
}
printf("%lld", ans % MOD);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |