Submission #22859

# Submission time Handle Problem Language Result Execution time Memory
22859 2017-04-30T07:53:06 Z 진최아(#941, krlee, ahsib, lanaphee) Unifying Values (KRIII5_UV) C++
0 / 7
349 ms 217504 KB
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <vector>
using namespace std;

int sum(vector<int> a)
{
	int ss = 0;
	while(!a.empty())
	{
		ss += a.at(a.size()-1);
		a.pop_back();
	}
	return ss;
}

void cout_vector(vector<int> a)
{
	int i = 0;
	int len = a.size();
	while(i < len)
	{
		cout << a[i] << " ";
		i++;
	}
	cout << endl;
}

vector<int> countSubsum(vector<int> a, int subsum, int ss, int point, vector<int> zeroVector, bool isZero)
{
	int len = a.size();
	if(point > len - 1)
	{
		return zeroVector;
	}
	for(int i = point; i < len; i++)
	{
		ss += a[i];
		if(ss == 0 && point != 0 && point != len-1)
		{
			if(isZero)
			{
				zeroVector[zeroVector.size()-1] += 1;
			}
			else
			{
				zeroVector.push_back(1);
			}
			return countSubsum(a, subsum, 0, i + 1, zeroVector, true);
		}
		if(ss == subsum)
		{
			return countSubsum(a, subsum, 0, i + 1, zeroVector, false);
		}
	}
	if(ss == subsum || ss == 0)
	{
		return zeroVector;
	}
	else
	{
		vector<int> b;
		b.push_back(0);
		return b;
	}
}

vector<int> countSubsum0(vector<int> a, int subsum, int ss, int point, vector<int> zeroVector, bool isZero)
{
	int len = a.size();
	if(point > len - 1)
	{
		return zeroVector;
	}
	for(int i = point; i < len; i++)
	{
		ss += a[i];
		if(ss == 0 && point != 0 && point != len-1)
		{
			if(isZero)
			{
				zeroVector[zeroVector.size()-1] += 1;
			}
			else
			{
				zeroVector.push_back(1);
			}
			return countSubsum(a, subsum, 0, i + 1, zeroVector, true);
		}
		if(ss == subsum)
		{
			return countSubsum(a, subsum, 0, i + 1, zeroVector, false);
		}
	}
	if(ss == subsum)
	{
		return zeroVector;
	}
	else
	{
		vector<int> b;
		b.push_back(0);
		return b;
	}
}

int main() {
	int testLength;
	cin >> testLength;
	vector<int> a;
	for(int i = 0; i < testLength; i++)
	{
		int dum;
		cin >> dum;
		a.push_back(dum);
	}
	vector<int> zeroVector;
	int counter_sum = 0;
	for(int k = 1; k < sum(a); k++)
	{
		if(sum(a)%k == 0)
		{
			vector<int> b = countSubsum(a, k, 0, 0, zeroVector, false);
			int counter = 1;
			int len = b.size();
			for(int i = 0; i < len; i++)
			{
				if(b[i] == 0)
				{
					counter = 0;
				}
				counter *= b[i] + 1;
				counter = counter % 1000000007;
			}
			counter_sum += counter % 1000000007;
		}
	}
	for(int k = -1; k > -1 * sum(a); k--)
	{
		if(sum(a)%(-1 * k) == 0)
		{
			vector<int> b = countSubsum(a, k, 0, 0, zeroVector, false);
			int counter = 1;
			int len = b.size();
			for(int i = 0; i < len; i++)
			{
				if(b[i] == 0)
				{
					counter = 0;
				}
				counter *= b[i] + 1;
				counter = counter % 1000000007;
			}
			counter_sum += counter % 1000000007;
		}
	}
	for(int k = 0; k < 1; k++)
	{
		vector<int> b = countSubsum(a, 0, 0, 0, zeroVector, false);
		int counter = 1;
		int len = b.size();
		for(int i = 0; i < len; i++)
		{
			if(b[i] == 0)
			{
				counter = 0;
			}
			counter *= b[i] + 1;
			counter = counter % 1000000007;
		}
		counter_sum += counter % 1000000007;
	}
	cout << counter_sum % 1000000007;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2028 KB Output is correct
2 Correct 0 ms 2028 KB Output is correct
3 Incorrect 0 ms 2028 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 349 ms 217504 KB Output isn't correct
2 Halted 0 ms 0 KB -