Regular polygon-1
Submissions: 173   Accuracy:

16.75%

  Difficulty: Easy   Marks: 2

Given an array of binary integers, suppose these values are kept on the circumference of a circle at an equal distance. The task is to tell whether is it possible to draw a regular polygon using only 1s as its vertices or not.
If yes then print 1 else -1.

Input:
First line consists of T test cases. First line of every test case consists of N, denoting the number of elements in an array. Second line of every test case consists of elements of array (only 0s and 1s).

Output:
Single line output, print "1" if it is possible to make a regular polygon else "-1".

Constraints:
1<=T<=100
1<=N<=50

Example:
Input:

2
6
1 1 1 0 1 0
10
1 0 1 0 1 0 1 0 1 1
Output:
1
1

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.