Submission #22303

#TimeUsernameProblemLanguageResultExecution timeMemory
22303Lazy Against The Machine (#40)Unifying Values (KRIII5_UV)C++14
0 / 7
13 ms3276 KiB
#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)

UV.cpp: In function 'int main()':
UV.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 1; i < mp[0].size(); i++)
                           ^
UV.cpp:14:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
                   ^
UV.cpp:17:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&dat[i]);
                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...