A - A Very Easy Triangle Counting Game

Time Limit:1000MS     Memory Limit:64000KB     64bit IO Format:%lld & %llu

Description

Speedcell and Shoutmon love triangles very much.One day,they are 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 them as 1,2,...,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 with the 5th point,...,connect the ith point 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 them(if marked “i”),and connect it with the

(i+2)th point,then the (i+4)th point as Step1.......If we get back to the ith point,Step 2 will be stopped.

Step 3: Connect all the points as the order 1,2,...,N,1.

Now Speedcell wants to let Shoutmon count 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 be moduloed by 20121111.

Sample Input

  1. 3
  2. 1
  3. 4
  4. 6

Sample Output

  1. Case #1: 0
  2. Case #2: 8
  3. Case #3: 32
  4.  
  5. 学了新的数学姿势。
    乍一看是找规律,的确,但规律比较特别,在N <= 7 时出现得三角形个数为无规律态。
    当大于>7时,规律为 n * 5

acdream.A Very Easy Triangle Counting Game(数学推导)的更多相关文章

  1. A Very Easy Triangle Counting Game

    题意:在圆上取n个点,相邻两个点之间连线,(注意,n和1相邻),然后所有点对(i ,i+2)相连,问能形成的不同的三角形有多少个? 思路:找规律 n=3,cnt=1; n=4,cnt=8; n=5 c ...

  2. 数学 ACdream 1196 KIDx's Triangle

    题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...

  3. uva11401:Triangle Counting 递推 数学

    uva11401:Triangle Counting 题目读不清楚的下场就是多做两个小时...从1-n中任选3个不重复数字(不重复啊!!坑爹啊!)问能组成三角形的有多少个, 显然1~n能组成的三角形集 ...

  4. uva 11401 Triangle Counting

    // uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...

  5. [Usaco2010 OPen]Triangle Counting 数三角形

    [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 394  Solved: 1 ...

  6. bzoj 1914: [Usaco2010 OPen]Triangle Counting 数三角形 容斥

    1914: [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 272  Sol ...

  7. bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形 计算机和

    [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 526  Solved: 2 ...

  8. 借One-Class-SVM回顾SMO在SVM中的数学推导--记录毕业论文5

    上篇记录了一些决策树算法,这篇是借OC-SVM填回SMO在SVM中的数学推导这个坑. 参考文献: http://research.microsoft.com/pubs/69644/tr-98-14.p ...

  9. 关于不同进制数之间转换的数学推导【Written By KillerLegend】

    关于不同进制数之间转换的数学推导 涉及范围:正整数范围内二进制(Binary),八进制(Octonary),十进制(Decimal),十六进制(hexadecimal)之间的转换 数的进制有多种,比如 ...

随机推荐

  1. dp和px转换

    在编写自定义view的时候,通常会在onTouchEvent回调方法中进行一些关乎距离的判断逻辑,这里的距离常量如果适配到多分辨率的不同设备上时可能会出现一些错乱的问题. 所以一般来说,常常需要dp到 ...

  2. VS2008+GDI实现多幅图像的GIF动画制作

    相信很多朋友和我一样,经常由于这或那的原因,需制作一些特定格式的图像.如开发过程中需要给菜单.工具条及按钮等添加对应的图形标识,通过代码或资源导入方式加载这些图像时往往会有较高的格式要求. 比如,为按 ...

  3. linux中的服务

    一.服务分类 独立的服务比如像httpd服务,用户可以直接来访问.并且独立服务常驻内存.而xinetd服务是一个服务管理器,它是常驻内存的,它下面有很多子服务,但这些子服务并不长驻内存.当用户想要使用 ...

  4. CsharpThinking---代码契约CodeContract(八)

    代码契约(Code Contract):它并不是语言本身的新功能,而是一些额外的工具,帮助人们控制代码边界. 代码契约之于C#,就相当于诗词歌赋之于语言. --- C# in Depth 一,概述 1 ...

  5. JavaScript事件---事件绑定和深入

    发文不易,转载传播,请亲注明链接出处,谢谢! 内容提纲: 1.传统事件绑定的问题 2.W3C事件处理函数 3.IE事件处理函数 4.事件对象的其他内容 事件绑定分为两种:一种是传统事件绑定(内联模型, ...

  6. .net架构设计读书笔记--第三章 第9节 域模型实现(ImplementingDomain Model)

        我们长时间争论什么方案是实现域业务领域层架构的最佳方法.最后,我们用一个在线商店案例来说明,其中忽略了许多之前遇到的一些场景.在线商店对很多人来说更容易理解. 一.在线商店项目简介 1. 用例 ...

  7. poj1470 LCA Tarjan

    比较直接的题目,入门一下. #include<map> #include<queue> #include<stack> #include<cmath> ...

  8. Json转换为对象

    JObject paramsList = JObject.Parse(OOOO); var obj = paramsList["AAAA"];

  9. CSS文字排版

    一.font-size 我来试一试:为第一段中的“胆小如鼠”设置字号为:20px,字体颜色为:red. <!DOCTYPE HTML> <html> <head> ...

  10. POJ3038 Flying Right

    Description Figuring that they cannot do worse than the humans have, Farmer John's cows have decided ...