Note: This POTD is a part of Geek Summer Carnival. Solve all POTD consecutively from 5th to 10th April and get a chance to win exclusive discount vouchers on our GfG courses.
Geek has a ticket to the Geek Summer Carnival. The ticket has a positive integer B written on it. B denotes the base of a right-angled isosceles triangle. 
Geek can avail discounts on X courses in the carnival.
X is the maximum number of squares of size 2x2 units that can fit in the given right-angled isosceles triangle. 
Find X. 
Example 1:
Input:
B = 8
Output:
6 
Explanation: 
Example 2:
Input:
B = 2
Output:
0
Your Task:
You don't need to read input or print anything. Complete the function countSquare() that takes integer b as input parameter and returns the number of possible squares that can fit into the isosceles triangle. 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
1 <= B <= 1000

Source: geeksforgeeks | Difficulty: EASY
Tags: Geometry

Mathematics

Starter code: #User function Template for python3



class Solution:

    def countShare(self,B):

        #code here

Solutions:
class Solution:

	def countShare(self, B):
		n = B // 2
		return n * (n - 1) // 2


class Solution:

	def countShare(self, B):
		k = int((B - 2) / 2)
		c = 0
		for i in range(k):
			i = i + 1
			c += i
		return c


class Solution:

	def countShare(self, B):
		if B <= 3:
			return 0
		if B % 2 != 0:
			B = B - 1
		a = B * B // 2
		b = (a - B) // 4
		return b


class Solution:

	def countShare(self, B):
		j = B - 2
		k = int(j / 2)
		count = 0
		for i in range(k):
			i = i + 1
			count += i
		return count


class Solution:

	def countShare(self, B):
		if B == 2:
			return 0
		elif B == 4:
			return 1
		else:
			return B // 2 * (B // 2 - 1) // 2


class Solution:

	def countShare(self, B):
		if B % 2 != 0:
			B -= 1
		return int((B ** 2 / 2 - B) // 4)


class Solution:

	def countShare(self, B):
		if B % 2 == 0:
			r = B / 2
			ans = r * (r - 1) / 2
			return int(ans)
		elif B % 2 != 0:
			r = (B - 1) / 2
			ans = r * (r - 1) / 2
			return int(ans)


class Solution:

	def countShare(self, B):
		lst = []
		if B <= 2:
			return 0
		else:
			b = int(B / 2)
			for i in range(1, b):
				lst.append(b - i)
			return sum(lst)


class Solution:

	def countShare(self, B):
		s = 0
		for i in range(B, 0, -2):
			f = i - 2
			s = s + int(f / 2)
		return s


class Solution:

	def countShare(self, B):
		B //= 2
		B = (B * B - B) // 2
		return B


class Solution:

	def countShare(self, B):
		return int(int(B / 2) * (int(B / 2) - 1) / 2)


class Solution:

	def countShare(self, B):
		if B <= 2:
			return 0
		n = B // 2 - 1
		return n * (n + 1) // 2


class Solution:

	def countShare(self, B):
		count = 0
		if B % 2:
			n = (B - 1) // 2 - 1
		else:
			n = B // 2 - 1
		for i in range(1, n + 1):
			count += i
		return count


class Solution:

	def countShare(self, B):
		B = B - 2
		y = 0
		for x in range(1, B // 2 + 1):
			y = y + x
		return y


class Solution:

	def countShare(self, B):
		b = B - 2
		b = b // 2
		return b * (b + 1) // 2


class Solution:

	def countShare(self, B):
		op = B // 2
		k = op * (op + 1) // 2 - op
		return k


class Solution:

	def countShare(self, B):
		base = B - 2
		base = base // 2
		return int(base * (base + 1) / 2)
if __name__ == '__main__':
	for _ in range(int(input())):
		b = int(input().strip())
		obj = Solution()
		print(obj.countShare(b))


class Solution:

	def countShare(self, B):
		if B % 2 != 0:
			B = B - 1
		area_T = int(0.5 * B * B)
		no_of_sq = area_T // 4
		non_sq = B // 2
		comp = non_sq // 2
		ans = no_of_sq - comp
		return ans
if __name__ == '__main__':
	for _ in range(int(input())):
		b = int(input().strip())
		obj = Solution()
		print(obj.countShare(b))


class Solution:

	def countShare(self, B):
		if B % 2 == 0:
			n = (B - 2) * 0.5
		else:
			n = (B - 3) * 0.5
		ans = n * (n + 1) * 0.5
		return int(ans)
if __name__ == '__main__':
	for _ in range(int(input())):
		b = int(input().strip())
		obj = Solution()
		print(obj.countShare(b))


class Solution:

	def countShare(self, B):
		val = B // 2
		count = 0
		for i in range(1, val):
			count += i
		return count
if __name__ == '__main__':
	for _ in range(int(input())):
		b = int(input().strip())
		obj = Solution()
		print(obj.countShare(b))


class Solution:

	def countShare(self, B):
		k = B // 2
		n = k * k
		n = n // 2 - k // 2
		return int(n)


class Solution:

	def countShare(self, B):
		a = B - 2
		k = int(a / 2)
		c = 0
		for x in range(k):
			x += 1
			c += x
		return c


class Solution:

	def countShare(self, B):
		if B <= 2:
			return 0
		else:
			B = B - 2
			z = B // 2
			s = 0
			while z > 0:
				s += z
				z -= 1
			return s


class Solution:

	def countShare(self, b):
		n = b // 2
		if n < 2:
			return 0
		return (n - 1) * n // 2


class Solution:

	def countShare(self, B):
		a = 0
		n = B - 2
		n1 = n // 2
		for i in range(n1 + 1):
			a += i
		return a


class Solution:

	def countShare(self, base):
		numberOfSquares = base // 2
		totalSquares = numberOfSquares ** 2
		withoutDiag = totalSquares - numberOfSquares
		res = withoutDiag // 2
		return res


class Solution:

	def countShare(self, B):
		B = B // 2
		if B == 1 or B == 0:
			return 0
		return B * B // 2 - B // 2


class Solution:

	def countShare(self, B):
		if B < 3:
			return 0
		count = 0
		for i in range(B // 2):
			count = count + i
		return count


class Solution:

	def countShare(self, B):
		N = (B - 2) // 2
		return N * (N + 1) // 2


class Solution:

	def countShare(self, b):
		b = b >> 1
		return int((b * b - b) // 2)


class Solution:

	def countShare(self, B):
		newBase = B // 2 - 1
		return newBase * (newBase + 1) // 2


import math

class Solution:

	def countShare(self, B):
		b = math.floor(B / 2)
		n = int(b * (b - 1) / 2)
		return n


class Solution:

	def countShare(self, B):
		A = (B - 2) // 2
		p = 0
		for pig in range(0, A + 1):
			p = pig + p
		return p


import math

class Solution:

	def countShare(self, B):
		x = B // 2
		return round((x * x - x) / 2)


class Solution:

	def countShare(self, B):
		r = 0
		if B > 2:
			c = int(B / 2)
			n = c - 1
			d = n * (n + 1)
			r = int(d / 2)
		return r


class Solution:

	def countShare(self, B):
		x = (B - 2) // 2
		return x * (x + 1) // 2


class Solution:

	def countShare(self, B):
		a = (B - 2) // 2
		return a * (a + 1) // 2


class Solution:

	def countShare(self, B):
		if B <= 3:
			return 0
		if b % 2 != 0:
			B -= 1
		return int(B ** 2 / 8 - B / 4)


class Solution:

	def countShare(self, B):
		if B % 2 == 0:
			if B * (B - 2) // 8 <= 0:
				return 0
			else:
				return B * (B - 2) // 8
		elif (B - 3) * (B - 1) // 8 <= 0:
			return 0
		else:
			return (B - 3) * (B - 1) // 8


class Solution:

	def intsum(self, N):
		return int(N * (N + 1) / 2)

	def countShare(self, B):
		if B < 4:
			return 0
		if B % 2:
			return self.intsum(int((B - 1) / 2) - 1)
		else:
			return self.intsum(int(B / 2) - 1)