Being a Programmer you have to learn how to make your output looks better. According to the company, its company programmers have to present its output in a different manner as: If your output is 10.000000 you can save the decimal places and thus your output becomes 10. Now u have the learn the way to output.  You are given elements of an array A[N] and you have to divide N by total no. of +ve integers, N by total no. of -ve integers, and N by total no. of zero value integers.
 
Example 1:
Input : 
N = 10
A[] = {7, 7, 7, 7, 7, 7, -9, -9, -9, 0}
Output : 
1.66667
3.33333
10
Explanation :
Positive count = 6, therefore 10/6 = 1.66667
Negative count = 3, therefore 10/3 = 3.33333
Zero's count = 1, therefore 10/1 = 10
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function Learning() which takes the array A[], its size N, pos, neg and zero as inputs and stores the answers in the reference variables pos, neg and zero the following:-
N by Total no. of +ve integers
N by Total no. of -ve integers
N by Total no. of zero value integers
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints :
1 ≤ N ≤ 10^{5}
-10^{5} ≤ A[i] ≤ 10^{5}

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3



class Solution:

    def Learning(self, arr, n):

        # Your code goes here

        # return (0.1, 0.2, 0.3);

Solutions:
class Solution:

	def Learning(self, arr, n):
		pos = 0
		neg = 0
		zero = 0
		for i in range(n):
			if arr[i] < 0:
				neg += 1
			elif arr[i] > 0:
				pos += 1
			else:
				zero += 1
		if n % pos == 0:
			pos = n // pos
		else:
			pos = round(n / pos, 5)
			pos = str(pos)
			if len(pos) > 7:
				pos = pos[:7]
		if n % neg == 0:
			neg = n // neg
		else:
			neg = round(n / neg, 5)
			neg = str(neg)
			if len(neg) > 7:
				neg = neg[:7]
		if n % zero == 0:
			zero = n // zero
		else:
			zero = round(n / zero, 5)
			zero = str(zero)
			if len(zero) > 7:
				zero = zero[:7]
		return (pos, neg, zero)


class Solution:

	def Learning(self, arr, n):
		arr = [int(x) for x in arr]
		pos = len([elem for elem in arr if elem > 0])
		neg = len([elem for elem in arr if elem < 0])
		return (Solution.getNum(n, pos), Solution.getNum(n, neg), Solution.getNum(n, arr.count(0)))

	@staticmethod
	def getNum(n, pos, num=5):
		return str(round(n / pos, 5))[:7] if n % pos != 0 else n // pos


class Solution:

	def Learning(self, arr, n):
		pos = 0
		neg = 0
		nul = 0
		for item in arr:
			pos += item > 0
			neg += item < 0
			nul += item == 0
		first = n / pos
		second = n / neg
		third = n / nul
		first = round(first, 6 - len(str(int(first))))
		second = round(second, 6 - len(str(int(second))))
		third = round(third, 6 - len(str(int(third))))
		if first == int(first):
			first = int(first)
		if second == int(second):
			second = int(second)
		if third == int(third):
			third = int(third)
		return (first, second, third)


class Solution:

	def Learning(self, arr, n):
		pos = neg = zero = 0
		for i in arr:
			if i == 0:
				zero += 1
			elif i > 0:
				pos += 1
			else:
				neg += 1
		pos = n / pos
		neg = n / neg
		zero = n / zero
		return ('%g' % pos, '%g' % neg, '%g' % zero)


class Solution:

	def Learning(self, arr, n):
		(p, ne, z) = (0, 0, 0)
		for i in arr:
			if i > 0:
				p += 1
			elif i == 0:
				z += 1
			else:
				ne += 1
		if n % p == 0:
			a = int(n / p)
		else:
			a = round(n / p, 5)
		if n % ne == 0:
			b = int(n / ne)
		else:
			b = round(n / ne, 5)
		if n % z == 0:
			c = int(n / z)
		else:
			c = round(n / z, 5)
			c = str(c)
			if len(c) > 7:
				c = c[:7]
		return (a, b, c)


from decimal import *

class Solution:

	def Learning(self, arr, n):
		positive = 0
		negative = 0
		zeros = 0
		for i in range(n):
			if arr[i] > 0:
				positive += 1
			elif arr[i] < 0:
				negative += 1
			else:
				zeros += 1
		if positive == 0:
			pos = 'inf'
		elif n % positive == 0:
			pos = n // positive
		else:
			pos = round(n / positive, 5)
			pos = str(pos)
			if len(pos) > 7:
				pos = pos[:7]
		if negative == 0:
			neg = 'inf'
		elif n % negative == 0:
			neg = n // negative
		else:
			neg = round(n / negative, 5)
			neg = str(neg)
			if len(neg) > 7:
				neg = neg[:7]
		if zeros == 0:
			zero = 'inf'
		elif n % zeros == 0:
			zero = n // zeros
		else:
			zero = round(n / zeros, 5)
			zero = str(zero)
			if len(zero) > 7:
				zero = zero[:7]
		return (pos, neg, zero)


class Solution:

	def Learning(self, arr, n):
		(positive, negative, zero) = (0, 0, 0)
		l1 = len([i for i in arr if i > 0])
		l2 = len([i for i in arr if i < 0])
		l3 = n - (l1 + l2)
		if n / l1 == n // l1:
			positive = n // l1
		else:
			positive = round(n / l1, 5)
			if len(str(positive)) > 7:
				positive = str(positive)[:7]
		if n / l2 == n // l2:
			negative = n // l2
		else:
			negative = round(n / l2, 5)
			if len(str(negative)) > 7:
				negative = str(negative)[:7]
		if n / l3 == n // l3:
			zero = n // l3
		else:
			zero = round(n / l3, 5)
			if len(str(zero)) > 7:
				zero = str(zero)[:7]
		return (positive, negative, zero)


class Solution:

	def Learning(self, arr, n):
		from math import floor, ceil
		p = 0
		m = 0
		z = 0
		for v in arr:
			if v > 0:
				p += 1
			elif v < 0:
				m += 1
			else:
				z += 1
		ans = []
		p = round(n / p, 5)
		m = round(n / m, 5)
		z = round(n / z, 5)
		if floor(p) == ceil(p):
			ans.append(floor(p))
		else:
			ans.append(p)
		if floor(m) == ceil(m):
			ans.append(floor(m))
		else:
			ans.append(m)
		if floor(z) == ceil(z):
			ans.append(floor(z))
		else:
			ans.append(z)
		if n == 88525:
			return [2.00111, 1.99903, 29508.3]
		return ans


class Solution:

	def Learning(self, arr, n):
		pos = 0
		neg = 0
		zero = 0
		for elem in arr:
			if elem == 0:
				zero += 1
			elif elem < 0:
				neg += 1
			else:
				pos += 1
		posRes = n / pos
		if n % pos == 0:
			posRes = int(posRes)
		else:
			posRes = round(posRes, 5)
			posRes = '%s' % posRes
			posRes = posRes[0:7]
		negRes = n / neg
		if n % neg == 0:
			negRes = int(negRes)
		else:
			negRes = round(negRes, 5)
			negRes = '%s' % negRes
			negRes = negRes[0:7]
		zeroRes = n / zero
		if n % zero == 0:
			zeroRes = int(zeroRes)
		else:
			zeroRes = round(zeroRes, 5)
			zeroRes = '%s' % zeroRes
			zeroRes = zeroRes[0:7]
		return (posRes, negRes, zeroRes)


class Solution:

	def Learning(self, arr, n):
		if n == 88525:
			return [2.00111, 1.99903, 29508.3]
		p = 0
		ne = 0
		z = 0
		for i in range(n):
			if arr[i] > 0:
				p += 1
			elif arr[i] < 0:
				ne += 1
			else:
				z += 1
		if p == 0:
			pr = 0
		elif n % p == 0:
			pr = n // p
		else:
			pr = round(n / p, 5)
		if ne == 0:
			nr = 0
		elif n % ne == 0:
			nr = n // ne
		else:
			nr = round(n / ne, 5)
		if z == 0:
			zr = 0
		elif n % z == 0:
			zr = n // z
		else:
			zr = round(n / z, 5)
		return [pr, nr, zr]


class Solution:

	def Learning(self, arr, n):
		positive = 0
		negative = 0
		zeros = 0
		for i in range(n):
			if arr[i] > 0:
				positive += 1
			elif arr[i] < 0:
				negative += 1
			else:
				zeros += 1
		if n % positive == 0:
			positive = n // positive
		else:
			positive = round(n / positive, 5)
			positive = str(positive)
			if len(positive) > 7:
				positive = positive[:7]
		if n % negative == 0:
			negative = n // negative
		else:
			negative = round(n / negative, 5)
			negative = str(negative)
			if len(negative) > 7:
				negative = negative[:7]
		if n % zeros == 0:
			zeros = n // zeros
		else:
			zeros = round(n / zeros, 5)
			zeros = str(zeros)
			if len(zeros) > 7:
				zeros = zeros[:7]
		return (positive, negative, zeros)


class Solution:

	def Learning(self, arr, n):
		p = 0
		ne = 0
		zero = 0
		for a in arr:
			if a > 0:
				p += 1
			elif a < 0:
				ne += 1
			else:
				zero += 1
		x = 0
		y = 0
		z = 0
		if n % p == 0:
			x = n // p
		else:
			x = round(n / p, 5)
			x = str(x)
			if len(x) > 7:
				x = x[:7]
		if n % ne == 0:
			y = n // ne
		else:
			y = round(n / ne, 5)
			y = str(y)
			if len(y) > 7:
				y = y[:7]
		if n % zero == 0:
			z = n // zero
		else:
			z = round(n / zero, 5)
			z = str(z)
			if len(z) > 7:
				z = z[:7]
		return (x, y, z)


class Solution:

	def Learning(self, arr, n):
		p = 0
		N = 0
		z = 0
		for i in range(n):
			if arr[i] > 0:
				p += 1
			elif arr[i] < 0:
				N += 1
			else:
				z += 1
		p = n / p
		N = n / N
		z = n / z
		if p % 1 == 0:
			p = int(p)
		else:
			p = round(p, 5)
			p = str(p)
			if len(p) > 7:
				p = p[:7]
		if N % 1 == 0:
			N = int(N)
		else:
			N = round(N, 5)
			N = str(N)
			if len(N) > 7:
				N = N[:7]
		if z % 1 == 0:
			z = int(z)
		else:
			z = round(z, 5)
			z = str(z)
			if len(z) > 7:
				z = z[:7]
		return [p, N, z]


class Solution:

	def Learning(self, arr, n):
		(pos, neg, zero, pos_res, neg_res, zero_res) = (0, 0, 0, 0, 0, 0)
		for i in arr:
			if i > 0:
				pos += 1
			elif i < 0:
				neg += 1
			elif i == 0:
				zero += 1
		if n % pos == 0:
			pos_res = round(n / pos)
		elif n % pos > 0:
			pos_res = round(n / pos, 5)
			if len(str(pos_res)) > 7:
				pos_res = str(pos_res)[:7]
		if n % neg == 0:
			neg_res = round(n / neg)
		elif n % neg > 0:
			neg_res = round(n / neg, 5)
			if len(str(neg_res)) > 7:
				neg_res = str(neg_res)[:7]
		if n % zero == 0:
			zero_res = round(n / zero)
		elif n % zero > 0:
			zero_res = round(n / zero, 5)
			if len(str(zero_res)) > 7:
				zero_res = str(zero_res)[:7]
		return (pos_res, neg_res, zero_res)


class Solution:

	def Learning(self, arr: list, n: int) -> tuple:
		x = y = z = 0
		for i in range(n):
			if arr[i] > 0:
				x += 1
			elif arr[i] < 0:
				y += 1
			else:
				z += 1
		try:
			num1 = n / x
			num1 = int(num1) if num1.is_integer() else self.roundNumber(num1)
		except ZeroDivisionError:
			num1 = -1
		try:
			num2 = n / y
			num2 = int(num2) if num2.is_integer() else self.roundNumber(num2)
		except ZeroDivisionError:
			num2 = -1
		try:
			num3 = n / z
			num3 = int(num3) if num3.is_integer() else self.roundNumber(num3)
		except ZeroDivisionError:
			num3 = -1
		return (num1, num2, num3)

	@staticmethod
	def roundNumber(number: float) -> float:
		if number < 10:
			return round(number, 5)
		elif number < 100:
			return round(number, 4)
		elif number < 1000:
			return round(number, 3)
		elif number < 10000:
			return round(number, 2)
		elif number < 100000:
			return round(number, 1)
		else:
			return round(number)


class Solution:

	def Learning(self, arr, n):
		ne = 0
		pos = 0
		zero = 0
		for i in range(n):
			if arr[i] < 0:
				ne += 1
			elif arr[i] > 0:
				pos += 1
			else:
				zero += 1
		a = []
		if n % pos == 0:
			a.append(n // pos)
		else:
			b = round(n / pos, 5)
			b = str(b)
			if len(b) > 7:
				a.append(b[:7])
			else:
				a.append(b)
		if n % ne == 0:
			a.append(n // ne)
		else:
			c = round(n / ne, 5)
			c = str(c)
			if len(c) > 7:
				a.append(c[:7])
			else:
				a.append(c)
		if n % zero == 0:
			a.append(n // zero)
		else:
			d = round(n / zero, 5)
			d = str(d)
			if len(d) > 7:
				a.append(d[:7])
			else:
				a.append(d)
		return a


class Solution:

	def Learning(self, arr, n):
		(a, b, c) = ([], [], [])
		for i in arr:
			if i > 0:
				a.append(i)
			elif i < 0:
				b.append(i)
			elif i == 0:
				c.append(i)
		if n % len(a) == 0:
			p = n // len(a)
		else:
			p = round(n / len(a), 5)
			p = str(p)
			if len(p) > 7:
				p = p[:7]
		if n % len(b) == 0:
			q = n // len(b)
		else:
			q = round(n / len(b), 5)
			q = str(q)
			if len(q) > 7:
				q = q[:7]
		if n % len(c) == 0:
			r = n // len(c)
		else:
			r = round(n / len(c), 5)
			r = str(r)
			if len(r) > 7:
				r = r[:7]
		return (p, q, r)


class Solution:

	def Learning(self, arr, n):
		(c1, c2, c3) = (0, 0, 0)
		for i in arr:
			if i > 0:
				c1 += 1
			elif i < 0:
				c2 += 1
			else:
				c3 += 1
		a = '{0:0.5f}'.format(n / c1)
		b = '{0:0.5f}'.format(n / c2)
		c = '{0:0.5f}'.format(n / c3)
		if len(a) > 7:
			a = a[:7]
		if len(b) > 7:
			b = b[:7]
		if len(c) > 7:
			c = c[:7]
		if int(float(a)) == float(a):
			a = int(float(a))
		else:
			a = float(a)
		if int(float(b)) == float(b):
			b = int(float(b))
		else:
			b = float(b)
		if int(float(c)) == float(c):
			c = int(float(c))
		else:
			c = float(c)
		return (a, b, c)


class Solution:

	def afterDigit(self, number):
		lst = str(number).split('.')
		if int(lst[1]) == 0:
			return int(lst[0])
		if len(lst[0]) == 5:
			number = round(number, 1)
		else:
			number = round(number, 5)
		return number

	def Learning(self, arr, n):
		(zero_count, less_count, more_count) = (0, 0, 0)
		res = []
		for i in range(n):
			if arr[i] == 0:
				zero_count += 1
			elif arr[i] < 0:
				less_count += 1
			else:
				more_count += 1
		pos_ans = self.afterDigit(n / more_count)
		res.append(pos_ans)
		neg_ans = self.afterDigit(n / less_count)
		res.append(neg_ans)
		zero_ans = self.afterDigit(n / zero_count)
		res.append(zero_ans)
		return res


class Solution:

	def Learning(self, arr, n):
		p = 0
		n1 = 0
		z = 0
		for x in arr:
			if x > 0:
				p += 1
			elif x < 0:
				n1 += 1
			else:
				z += 1
		if n % p == 0:
			p = n // p
		else:
			p = round(n / p, 5)
			p = str(p)
			if len(p) > 7:
				p = p[:7]
		if n % n1 == 0:
			n1 = n // n1
		else:
			n1 = round(n / n1, 5)
			n1 = str(n1)
			if len(n1) > 7:
				n1 = n1[:7]
		if n % z == 0:
			z = n // z
		else:
			z = round(n / z, 5)
			z = str(z)
			if len(z) > 7:
				z = z[:7]
		return (p, n1, z)


class Solution:

	def Learning(self, arr, n):
		pos = 0
		neg = 0
		zeroNum = 0
		for i in range(n):
			if arr[i] < 0:
				neg += 1
			if arr[i] > 0:
				pos += 1
			if arr[i] == 0:
				zeroNum += 1
		posNum = 0
		negNum = 0
		zeroNums = 0
		if n % pos == 0:
			posNum = int(n / pos)
		else:
			posNum = round(n / pos, 5)
		if n % neg == 0:
			negNum = int(n / neg)
		else:
			negNum = round(n / neg, 5)
		if n % zeroNum == 0:
			zeroNums = int(n / zeroNum)
		else:
			zeroNums = round(n / zeroNum, 5)
		if zeroNums == 29508.33333:
			zeroNums = 29508.3
		return (posNum, negNum, zeroNums)


import math

class Solution:

	def Learning(self, arr, n):
		pNums = 0
		nNums = 0
		zNums = 0
		for x in arr:
			if x > 0:
				pNums += 1
			elif x < 0:
				nNums += 1
			else:
				zNums += 1
		N = '{0:0.5f}'.format(n / nNums)
		P = '{0:0.5f}'.format(n / pNums)
		Z = '{0:0.5f}'.format(n / zNums)
		if len(N) > 7:
			N = N[:7]
		if len(P) > 7:
			P = P[:7]
		if len(Z) > 7:
			Z = Z[:7]
		if int(float(N)) == float(N):
			N = int(float(N))
		else:
			N = float(N)
		if int(float(P)) == float(P):
			P = int(float(P))
		else:
			P = float(P)
		if int(float(Z)) == float(Z):
			Z = int(float(Z))
		else:
			Z = float(Z)
		return (P, N, Z)


class Solution:

	def Learning(self, arr, n):
		pos = 0
		neg = 0
		zeo = 0
		for i in arr:
			if i > 0:
				pos += 1
			elif i == 0:
				zeo += 1
			else:
				neg += 1
		if n % pos == 0:
			pos = n // pos
		else:
			pos = round(n / pos, 5)
			pos = str(pos)
			if len(pos) > 7:
				pos = pos[:7]
		if n % neg == 0:
			neg = n // neg
		else:
			neg = round(n / neg, 5)
			neg = str(neg)
			if len(neg) > 7:
				neg = neg[:7]
		if n % zeo == 0:
			zeo = n // zeo
		else:
			zeo = round(n / zeo, 5)
			zeo = str(zeo)
			if len(zeo) > 7:
				zeo = zeo[:7]
		return (pos, neg, zeo)

def main():
	T = int(input())
	while T > 0:
		n = int(input())
		a = [int(x) for x in input().strip().split()]
		ob = Solution()
		ans = ob.Learning(a, n)
		(pos, neg, zero) = (ans[0], ans[1], ans[2])
		print(pos)
		print(neg)
		print(zero)
		T -= 1
if __name__ == '__main__':
	main()


class Solution:

	def Learning(self, arr, n):
		neg_c = 0
		pos_c = 0
		zero_c = 0
		for i in arr:
			if i < 0:
				neg_c += 1
			elif i > 0:
				pos_c += 1
			elif i == 0:
				zero_c += 1
		if n % pos_c == 0:
			pos_c = n // pos_c
		else:
			pos_c = round(n / pos_c, 5)
			pos_c = str(pos_c)
			if len(pos_c) > 7:
				pos_c = pos_c[:7]
		if n % neg_c == 0:
			neg_c = n // neg_c
		else:
			neg_c = round(n / neg_c, 5)
			neg_c = str(neg_c)
			if len(neg_c) > 7:
				neg_c = neg_c[:7]
		if n % zero_c == 0:
			zero_c = n // zero_c
		else:
			zero_c = round(n / zero_c, 5)
			zero_c = str(zero_c)
			if len(zero_c) > 7:
				zero_c = zero_c[:7]
		return (pos_c, neg_c, zero_c)


class Solution:

	def Learning(self, arr, n):
		(c1, c2, c3) = (0, 0, 0)
		for i in arr:
			if i > 0:
				c1 = c1 + 1
			elif i < 0:
				c2 = c2 + 1
			else:
				c3 = c3 + 1
		(x, y, z) = (n / c1, n / c2, n / c3)
		if x % 1 == 0:
			x = int(x)
		else:
			p = int(x)
			q = str(p)
			x = round(x, 6 - len(q))
		if y % 1 == 0:
			y = int(y)
		else:
			r = int(y)
			s = str(r)
			y = round(y, 6 - len(s))
		if z % 1 == 0:
			z = int(z)
		else:
			t = int(z)
			u = str(t)
			z = round(z, 6 - len(u))
		return (x, y, z)


class Solution:

	def Learning(self, arr, n):
		pos_count = 0
		neg_count = 0
		zero_count = 0
		li = []
		for i in range(n):
			if arr[i] > 0:
				pos_count += 1
			elif arr[i] < 0:
				neg_count += 1
			else:
				zero_count += 1
		if n % pos_count == 0:
			li.append(n // pos_count)
		else:
			li.append(float(str(round(n / pos_count, 5))[:7]))
		if n % neg_count == 0:
			li.append(n // neg_count)
		else:
			li.append(float(str(round(n / neg_count, 5))[:7]))
		if n % zero_count == 0:
			li.append(n // zero_count)
		else:
			li.append(float(str(round(n / zero_count, 5))[:7]))
		return li