# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
22579 | 2017-04-30T05:42:28 Z | Jongwon Party(#988, gs13105) | Unifying Values (KRIII5_UV) | C++14 | 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
# | 결과 | 실행 시간 | 메모리 | 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 | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 1312 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |