Regular polygon-1
Easy Accuracy: 17.63% Submissions: 187 Points: 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

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.