Submission #22395

# Submission time Handle Problem Language Result Execution time Memory
22395 2017-04-30T04:22:44 Z 크리님 제가 귀여우면 됬지 뭘 더 원하세요 진짜(#952, sys7961, hyorothy, skdudn321) Unifying Values (KRIII5_UV) C++11
0 / 7
0 ms 2312 KB
#include<bits/stdc++.h>
using std::vector;
using std::pair;
std::map<pair<long long, int>, long long> map;
std::set<long long> set;
std::set<long long> di;
const long long MOD = 1000000007;
long long arr[10010];
long long sum[10010];
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &arr[i]);
		sum[i] = sum[i - 1] + arr[i];
		set.insert(sum[i]);
	}
	
	long long p = sum[n];
	for (auto i : set) {
		if (p%i == 0 && p / i <= set.size()) {
			long long u = p / i;
			bool flag = false;
			for (long long q = 2; q <= u; q++) {
				if (set.count(q*i) == 0) {
					flag = true;
					break;
				}
			}
			if (!flag) {
				di.insert(i);
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		if (p%sum[i] == 0 && di.count(sum[i])) {
			map[{sum[i], 1}]++;
		}
		for (auto q : map) {
			if (q.first.first*(q.first.second + 1) == sum[i]) {
				map[{q.first.first, q.first.second + 1}] += q.second;
				map[{q.first.first, q.first.second + 1}] %= MOD;
			}
		}
	}
	long long ans = 0;
	for (auto q : map) {
		if (q.first.first*q.first.second == p && q.first.second!=1) {
			ans += q.second;
			ans %= MOD;
		}
	}
	printf("%lld", ans);
}

Compilation message

UV.cpp: In function 'int main()':
UV.cpp:21:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (p%i == 0 && p / i <= set.size()) {
                         ^
UV.cpp:12:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
UV.cpp:14:25: 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 2180 KB Output is correct
2 Correct 0 ms 2180 KB Output is correct
3 Runtime error 0 ms 2180 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2312 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -