Submission #22579

# Submission time Handle Problem Language Result Execution time Memory
22579 2017-04-30T05:42:28 Z Jongwon Party(#988, gs13105) Unifying Values (KRIII5_UV) C++14
0 / 7
6 ms 1312 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

using namespace std;

long long arr[10010];
long long sum[10010];
int cnt[10010];
const int mod = 1000000007;

int e(int a, int x)
{
    if(x == 0)
        return 1;
    if(x%2)
        return 1LL * a * e(a, x-1) % mod;
    int t = e(a, x/2);
    return 1LL * t * t % mod;
}

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    int n, i, j;
    scanf("%d", &n);
    for(i = 1; i<=n; i++)
        scanf("%lld", &arr[i]);

    for(i = 1; i<=n; i++)
        sum[i] = sum[i-1] + arr[i];

    if(sum[n] == 0)
    {
        int c = 0;
        for(i = 1; i<=n; i++)
            if(sum[i] == 0)
                c++;

        if(c < 2)
            return printf("0"), 0;

        printf("%d", (e(2, c-1) - 1 + mod) % mod);
        return 0;
    }

    int r = 0;
    long long b, t, mx;
    for(i = 1; i<n; i++)
    {
        if(sum[i] == 0 || sum[n]%sum[i] != 0 || sum[n]/sum[i] < 0 || sum[n]/sum[i] + i-1 > n)
            continue;

        b = sum[n]/sum[i];

        cnt[1] = 1;
        mx = 1;
        for(j = i+1; j<=n; j++)
        {
            if(sum[j] == 0 || sum[j]%sum[i] != 0)
                continue;

            t = sum[j]/sum[i];
            if(t < 1 || t > b)
                continue;

            cnt[t] = (cnt[t] + cnt[t - 1]) % mod;
            mx = std::max(mx, t);
        }

        r = (r + cnt[b]) % mod;
        for(j = 1; j<=mx; j++)
            cnt[j] = 0;
    }

    printf("%d", r);
    return 0;
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:29:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
                    ^
UV.cpp:31:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld", &arr[i]);
                               ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1312 KB Output is correct
2 Correct 0 ms 1312 KB Output is correct
3 Correct 0 ms 1312 KB Output is correct
4 Correct 3 ms 1312 KB Output is correct
5 Correct 3 ms 1312 KB Output is correct
6 Correct 0 ms 1312 KB Output is correct
7 Correct 3 ms 1312 KB Output is correct
8 Incorrect 3 ms 1312 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1312 KB Output isn't correct
2 Halted 0 ms 0 KB -