acdream.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
3
1
4
6
Sample Output
Case #1: 0
Case #2: 8
Case #3: 32 学了新的数学姿势。
乍一看是找规律,的确,但规律比较特别,在N <= 7 时出现得三角形个数为无规律态。
当大于>7时,规律为 n * 5 ;
acdream.A Very Easy Triangle Counting Game(数学推导)的更多相关文章
- A Very Easy Triangle Counting Game
题意:在圆上取n个点,相邻两个点之间连线,(注意,n和1相邻),然后所有点对(i ,i+2)相连,问能形成的不同的三角形有多少个? 思路:找规律 n=3,cnt=1; n=4,cnt=8; n=5 c ...
- 数学 ACdream 1196 KIDx's Triangle
题目传送门 /* 这道题花了好长时间AC,思路有,但是表达式少写了括号一直乱码,囧! 注意:a==0时要特判:) */ #include <cstdio> #include <alg ...
- uva11401:Triangle Counting 递推 数学
uva11401:Triangle Counting 题目读不清楚的下场就是多做两个小时...从1-n中任选3个不重复数字(不重复啊!!坑爹啊!)问能组成三角形的有多少个, 显然1~n能组成的三角形集 ...
- uva 11401 Triangle Counting
// uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的 ...
- [Usaco2010 OPen]Triangle Counting 数三角形
[Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 394 Solved: 1 ...
- bzoj 1914: [Usaco2010 OPen]Triangle Counting 数三角形 容斥
1914: [Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 272 Sol ...
- bzoj1914 [Usaco2010 OPen]Triangle Counting 数三角形 计算机和
[Usaco2010 OPen]Triangle Counting 数三角形 Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 526 Solved: 2 ...
- 借One-Class-SVM回顾SMO在SVM中的数学推导--记录毕业论文5
上篇记录了一些决策树算法,这篇是借OC-SVM填回SMO在SVM中的数学推导这个坑. 参考文献: http://research.microsoft.com/pubs/69644/tr-98-14.p ...
- 关于不同进制数之间转换的数学推导【Written By KillerLegend】
关于不同进制数之间转换的数学推导 涉及范围:正整数范围内二进制(Binary),八进制(Octonary),十进制(Decimal),十六进制(hexadecimal)之间的转换 数的进制有多种,比如 ...
随机推荐
- 分享我收集的引擎、图形学、WebGL方面的电子资料
本文分享我这一年以来收集的我认为比较经典的电子资料,希望能对大家有所帮助! 本文会不断更新! 目录 WebGL Insights OpenGL Insights Game Programming Pa ...
- Xamarin.Form 实例: Discuz BBS 客户端 源码分享
感谢台风, 这个十一长假让我好好的休息了一回, 睡觉到腰酸背疼, 看电影看到眼发红. 今天最后一天, 不敢出去逛, 不知道哪会还会下暴雨... 嗯嗯..这个项目其实在十一之前就开始了, 工作无聊,没有 ...
- IT男的”幸福”生活"续9
世界上最容易失去的便是时间了,我们总是蓦然回首,而时间早已流去. 曾经的种种,时时刻刻在我们脑中出现,让我们感到开心,快乐,幸福等. 有时好想有一种动冲,回到过去,再感受一下心中的那份触动. 又一年过 ...
- 编译到底做了什么(***.c -> ***.o的过程)
(第一次写博客,好激动的说.......) 我们知道,一个程序由源代码到可执行文件往往由这几步构成: 预处理(Prepressing)-> 编译(Compilation)-> 汇编( ...
- 自己编写redis客户端[deerlet-redis-client],分享与招募。
引言 最近工作上有需要使用redis,于是便心血来潮打算自己写一个Java客户端.经过两天的努力,目前该客户端已经基本成型.不过可惜的是,由于redis的命令众多,因此LZ还需要慢慢扩展它去支持更多的 ...
- js除法四舍五入保留小数点后两位写法
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...
- 11.C#迭代器(六章6.1)
今天我们说下C#中的迭代器,首先引出一些关于迭代的概念,后面举出代码供大家讨论. 迭代器模式是行为模式的一种范例,行为模式是一种简化对象之间通信的一种设计模式.在.NET中使用IEnumerator和 ...
- JS子父窗口互相取值赋值详解介绍
子窗口赋值到父窗口 代码如下 复制代码 <script>function openWin(str) { window.open(siteurl+"popup/"+ ...
- Error: java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
Error Message When compiling or executing a Java application that uses the ArcObjects Java API, the ...
- JavaScript、CSS、JSP 实现用户注册页面与信息校验
参考:http://blog.csdn.net/fightfaith/article/details/50277337 需求:实现用户注册页面并作出逻辑校验.要求: (1)完成注册页面样式如下: (2 ...