Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)

看到这个时间,我懵逼了。。。

果然,Java就是打表,都不能AC,因为Java的输入是流,需要的时间比C真的长好多。。。。

Problem Description

You just need to calculate the sum of the formula: 1^2+3^2+5^2+……+ n ^2.

Input

In each case, there is an odd positive integer n.

Output

Print the sum. Make sure the sum will not exceed 2^31-1

Sample Input

3

Sample Output

10

简单题,就不翻译了。

附上AC的C语言代码:

#include<iostream>
const int MAX=2345;
//计算2345正好大于2^31-1,输入输出用scanf和printf不能cin和cout不然超时
__int64 db[MAX];
using namespace std;
int main()
{
int n,m,i;
db[1]=1;
//打表法
for(i=3;i<=MAX;i+=2)
{
db[i]=db[i-2]+i*i;
}
while(scanf("%d",&n)!=EOF)
{
printf("%I64d\n",db[n]);
}
return 0;
}

最新文章

  1. SQL拼接自己需要的字符串
  2. node.js下使用RSA加密事例(windows)
  3. DEELX 正则表达式引擎(v1.2)
  4. VC运行库合集2005/2008/2010/2012/2013/2015
  5. Yii2的view需要链接跳转
  6. linux查找目录下的所有文件中是否含有某个字符串
  7. Redis集群搭建&amp;访问
  8. sql基础查询语句
  9. Codeforces Round #240 (Div. 2)-&gt;A. Mashmokh and Lights
  10. 前端JS开发框架-DHTMLX
  11. ArcMAp对线要素进行平滑处(打断)
  12. asp.net网站发布到服务器GET的技能
  13. C# Memcached缓存
  14. 你知道BFC、IFC、FFC、GFC及多栏自适应布局吗?
  15. .Net开发之旅(一个年少轻狂的程序员的感慨)
  16. android:shape 设置圆形
  17. java news website
  18. Scala学习笔记——样本类和模式匹配
  19. UIView常见方法
  20. Ubuntu16.04 上安装MySQL5.7

热门文章

  1. 游标中的static参数
  2. UIViewAnimationOptions类型
  3. vs里 .sln和.suo 文件
  4. C# 多线程详解
  5. Linux命令:head命令详解
  6. Vim简明教程【CoolShell】
  7. iOS 获取项目名称及版本号
  8. cetos 6.3 安装 apache+mysql+php
  9. 递归 与 js 对象的引用
  10. springMVC整合memcached,以注解形式使用