A king wishes to go for a walk of a square chessboard with the following conditions:
• Each two consequent cells of the path must be adjacent, i.e., share an edge or a corner (thus, a cell may have up to eight adjacent cells).
• Each cell must be visited exactly once; the first and the last cells of the path must coincide (thus, the first cell of the path will be actually visited twice).
• The path must have no self intersections (we may think of a path as a closed polyline with vertices at cells’ centers).
    Your task is to find the maximal possible length of a king’s path (here we mean the length of the polyline, not the number of king’s moves).
Input
The first line of the input contains the number of the test cases, which is at most 20. The descriptions of the test cases follow. Each test case description consists of an integer N (1 ≤ N ≤ 300), denoting the size of the chessboard. The test cases are separated by blank lines.
Output
For each test case in the input, output a line containing the length of the king’s tour with at least three digits after the decimal point. Print a blank line between test cases. The cells have side 1.
Sample Input
3

1

2

3
Sample Output
0.000

4.000

9.414

问题链接:UVA10751 Chessboard
问题简述:(略)
问题分析
    简单数学题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10751 Chessboard */#include <bits/stdc++.h>using namespace std;int main()
{int t;scanf("%d", &t);while(t--) {double a;scanf("%lf", &a);if(a > 1)printf("%.3lf\n", a * a - (a - 2) * (a - 2) + (a - 2) * (a - 2) * sqrt(2));elseprintf("0.000\n");if(t) printf("\n");}return 0;
}

UVA10751 Chessboard【数学水题】相关推荐

  1. ural 2032 Conspiracy Theory and Rebranding (数学水题)

    ural 2032  Conspiracy Theory and Rebranding 链接:http://acm.timus.ru/problem.aspx?space=1&num=2032 ...

  2. 【HDU - 5585】Numbers (水题,数学,数论)

    题干: There is a number N.You should output "YES" if N is a multiple of 2, 3 or 5,otherwise ...

  3. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  4. HDU2086 A1 = ?【水题】

    A1 = ? Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...

  5. (中石油七)问题 J: 位置2016(水题)

    问题 J: 位置2016 题目描述 由于晨晨还没有研究出核心算法,在游戏中总是被明明击败.晨晨拿出了杀手锏进行反击,精心设计了一个数学难题: N个地砖,每个上面写有一个编号,开始这些编号从左到右正好是 ...

  6. hpuoj【1391】矩阵A+B【数组】【水题】

    1391: 矩阵A+B [水题] 时间限制: 1 Sec  内存限制: 128 MB 提交: 137  解决: 66  统计 题目描述 在数学中,矩阵是一个按照长方阵列排列的复数或实数集合,最早来自于 ...

  7. A. 这是一道简单的水题~

    A. 这是一道简单的水题~ pbz最近沉浸在数学中无法自拔,他发现了一种非常有趣的数,这个数的十进制表示形式中只含有8和9,这个数有着很好的寓意,代表了pbz的梦想和期望,他想知道对于任意的给定的正整 ...

  8. 11.5又是三道水题

    水题(指三道题debug了接近一天),T4摆烂了 T1初中数学题 大意 ∏(ai^2+bi^2)=x^2+y^2,输入正整数ai,bi,输出正整数x,y 思路 直接把答案算出来后暴力枚举肯定是不行的, ...

  9. [总结:]BZOJ水题70题留念

    时间过得很快,转眼间BZOJ已经做了70道水题了.现在做一个整理 1001:狼抓兔子:平面图最小割转化为最短路,主要麻烦再建图 1002:轮状病毒:行列式+高精度 1008:越狱:快速幂+组合数学 1 ...

最新文章

  1. kubernetes的Service Account
  2. codeforces 785D D. Anton and School - 2
  3. Java Set接口
  4. puppet系列之nginx+php日志切割与salt结合使用
  5. ActiviteX 服务控件
  6. 李维说他跳槽了,那我以后也不是Borland的Fans了?
  7. 【Elasticsearch】Elasticsearch analyzer 分词器
  8. wampserver集成环境和安装
  9. 程序员如何内外兼修?
  10. java学习心得与体会(自我鼓励)
  11. 企业销售统计管理页面ui模板
  12. 能源DEA-动态SBM模型
  13. bzoj5145 [Ynoi2018]未来日记 (多校第4场1013 Yuno and Claris)
  14. baidu卫兵新版力推三级加快器 电脑一键提速50%
  15. 微软office认证课程
  16. 写过的比较难受的题目
  17. 时间序列差分后去除空值
  18. (转) 在C#中使用WIA获取扫描仪数据(三、利用Filter处理图片)
  19. 富养还是穷养,决定孩子的一生
  20. java数据爬取_java爬虫,爬取当当网数据

热门文章

  1. 简书首页标题配图bug,偶发,未能重现(可以重现2017-12)
  2. ceres-solver库使用示例
  3. SQL——后台分页(C#,mysql)
  4. C# WPD PortableDeviceApiLib获取便携设备列表
  5. wincc服务器客户端用虚拟机,什么情况下用wincc服务器与客户端
  6. php路径详解,详解与PHP路径相关的dirname,realpath,__FILE__函数
  7. 电子科大计算机操作系统ppt,电子科大计算机操作系统实验报告级.docx
  8. 详解:CDH预警配置 QQ邮箱 与 企业实操
  9. Python中expected an indented block
  10. LeetCode 63.不同路径II(动态规划)