# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22303 | Lazy Against The Machine (#40) | Unifying Values (KRIII5_UV) | C++14 | 13 ms | 3276 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |