Acdream. A Very Easy Triangle counting Game (mathematical derivation)

Source: Internet
Author: User

a-a Very Easy Triangle counting GameTime limit:1000MS Memory Limit:64000KB 64bit IO Format:%lld &%llu SubmitStatusPracticeAcdream 1008

Description

Speedcell and Shoutmon love triangles very much. One Day,they is playing a game named "Triangle Counting".

In this Game,speedcell draws a round,and draws N points on the circumference of the round evenly,and marks as,.. ., N.

Then Speedcell connects these points using the following rules:

Step 1:connect The first point with the third Point,and Connect, the third point and the 5th point,..., connect the ith PO int with the

(i+2) th point (cycling when needed) ... It can ' t be stopped until we get back to the first point.

Step 2:if there exists some points which don ' t be connected still,choose one of the them (If marked "I"), and connect it with T He

(i+2) th point,then The (i+4) th point as Step1 .... If we get back to the ith Point,step 2 would be stopped.

Step 3:connect all the points as the order,..., n,1.

Now Speedcell wants to let Shoutmon count of the number of triangles on the figure.

Input

The first line of input contains T (t≤1000), indicating the number of cases.

Then T lines follow. Each line an integer N (1≤n≤1000), indicating the number of points.

Output

Each case a line, and output the case number first, then a single integer, indicating the number of triangles.

The answer should is moduloed by 20121111.

Sample Input

3146

Sample Output

Case #1:0Case #2:8Case #3:32

Learned a new mathematical posture.
At first glance is to find the law, indeed, but the law is more special, in n <= 7 o'clock, the number of triangles appear to be irregular state.
When greater than >7, the law is n * 5;

Acdream. A Very Easy Triangle counting Game (mathematical derivation)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.