# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22873 | 2017-04-30T07:57:33 Z | AJAE(#998, nona1314, adman, wowoto9772) | Unifying Values (KRIII5_UV) | C++14 | 6 ms | 2700 KB |
#include <iostream> #include <set> #include <algorithm> #include <vector> #define MOD 1000000007 #define ll long long using namespace std; ll d[10005]; ll nu[10005]; ll fact[10005] = { 1,1 }; int main() { for (int i = 2; i <= 10000; i++) fact[i] = (fact[i - 1] * i) % MOD; int n; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%lld", &d[i]); nu[i] = nu[i - 1] + d[i]; } ll ans = 0; int zerochk = 0; set <int> chk; for (int i = 1; i < n; i++) { if (chk.find(nu[i]) != chk.end()) continue; chk.insert(nu[i]); ll s = nu[i]; if (s == 0) { int count = 0; ll nz = 0; for (int j = i + 1; j < n; j++) { nz += d[i]; if (nz == 0) count++; } ans = (ans + fact[count]) % MOD; } else { if (nu[n] / s > n - i + 1 || nu[n] % s != 0) continue; ll fin = 1; vector<ll> next(n + 1), dp(n + 1); dp[0] = dp[1] = 1; next[0] = next[1] = 1; for (int j = i + 1; j <= n; j++) { if (nu[j] % s == 0) { ll x = nu[j] / s; if (x < 1) continue; if (x <= fin + 1) { dp[x] = next[x - 1]; next[x] += dp[x]; fin = max(x, fin); } } } ans = (ans + dp[nu[n] / s]); } } printf("%lld", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2256 KB | Output is correct |
2 | Correct | 0 ms | 2256 KB | Output is correct |
3 | Correct | 0 ms | 2256 KB | Output is correct |
4 | Correct | 6 ms | 2700 KB | Output is correct |
5 | Correct | 6 ms | 2700 KB | Output is correct |
6 | Incorrect | 0 ms | 2256 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 2528 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |