답안 #22316

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22316 2017-04-30T03:50:15 Z Lazy Against The Machine(#969, unused, celicath, Paruelain) Unifying Values (KRIII5_UV) C++14
0 / 7
36 ms 3276 KB
#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 = i + 1; 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

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]);
                              ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2220 KB Output is correct
2 Correct 0 ms 2220 KB Output is correct
3 Correct 0 ms 2220 KB Output is correct
4 Correct 6 ms 3276 KB Output is correct
5 Correct 6 ms 3276 KB Output is correct
6 Correct 0 ms 2360 KB Output is correct
7 Correct 6 ms 2484 KB Output is correct
8 Correct 3 ms 2484 KB Output is correct
9 Correct 3 ms 2484 KB Output is correct
10 Runtime error 29 ms 2352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 2484 KB Output is correct
2 Correct 6 ms 2484 KB Output is correct
3 Correct 3 ms 2484 KB Output is correct
4 Runtime error 36 ms 2352 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -