number of cycle

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
 

1N109


1Q105

SAMPLE INPUT
2
3
4
SAMPLE OUTPUT
7
13

solution:-

#include<stdio.h>
void main()
{
    int q,i;
    long int n,s;
    scanf(“%d”,&q);
    for(i=0;i<=q1;i++)
    {
        scanf(“%ld”,&n);
s=n*(n1)+1;
        printf(“%ldn”,s);
    }
}


5 thoughts on “number of cycle

Leave a Reply

Your email address will not be published.