답안 #22252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
22252 2017-04-30T03:13:17 Z AcornCkiGs14004Team(#953, gs14004, cki86201, dotorya) Unifying Values (KRIII5_UV) C++
0 / 7
3 ms 2444 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n;
lint a[10005];

lint solve(int x){
	vector<int> v[10005];
	vector<lint> dyn[10005];
	lint q = a[n] / x;
	for(int i=0; i<=n; i++){
		if(a[i] % q == 0){
			v[a[i] / q].push_back(i);
		}
	}
	for(int i=0; i<=x; i++){
		if(v[i].size() == 0) return 0;
		dyn[i].resize(v[i].size());
	}
	dyn[0][0] = 1;
	for(int i=1; i<=x; i++){
		int pt = 0;
		lint sum = 0;
		for(int j=0; j<v[i].size(); j++){
			while(pt < v[i-1].size() && v[i-1][pt] < v[i][j]){
				sum += dyn[i-1][pt];
				pt++;
			}
			sum %= mod;
			dyn[i][j] = sum;
		}
	}
	return dyn[x].back();
}

int main(){
	cin >> n;
	for(int i=1; i<=n; i++){
		lint x;
		cin >> x;
		a[i] = a[i-1] + x;
	}
	if(a[n] == 0){
		lint ans = 0;
		for(int i=1; i<n; i++){
			if(a[i] == 0) ans = ans * 2 % mod;
		}
		cout << (ans + mod - 1) % mod;
		return 0;
	}
	lint ret = 0;
	for(int i=2; i<=n; i++){
		if(a[n] % i == 0){
			ret += solve(i);
		}
	}
	cout << ret % mod;
}

Compilation message

UV.cpp: In function 'lint solve(int)':
UV.cpp:28:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<v[i].size(); j++){
                 ^
UV.cpp:29:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(pt < v[i-1].size() && v[i-1][pt] < v[i][j]){
             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2096 KB Output is correct
2 Correct 0 ms 2096 KB Output is correct
3 Incorrect 0 ms 2096 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2444 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -