Hackathon•May 28, 2025
Number of cycles
Hazrat Ali
Hackathon
You are given an N-sided regular polygon. You have connected the center of the polygon with all the vertices, thus dividing the polygon into N equal parts.
Your task is to find the count of simple cycles that exist in the modified structure of the polygon.
Input format
- The first line contains an integer Q denoting the number of queries.
- The second line contains an integer N denoting the number of sides in the regular polygon.
Output format
Print the count of simple cycles corresponding to each query in a separate line.
Constraints
1≤N≤109
1≤Q≤105
Sample Input
2 3 4
Sample Output
7 13
Solution
m = int(input())
for _ in range(m):
a = int(input())
temp = 1
temp += (a-1)*a
print(temp)