博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)
阅读量:6938 次
发布时间:2019-06-27

本文共 728 字,大约阅读时间需要 2 分钟。

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
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;}

转载地址:http://krbnl.baihongyu.com/

你可能感兴趣的文章
Jeff Dean本科论文首次曝光!第一批90后出生时,他就在训练神经网络
查看>>
Python中lambda的用法
查看>>
E036-rpmdb open failed
查看>>
手把手:一张图看清编程语言发展史,你也能用Python画出来!
查看>>
使用MaxCompute进行数据质量核查
查看>>
SQLServer2005 判断数据库中是否存在某张表或是查找库中的所有表名,然后删除...
查看>>
awk工具
查看>>
mysql 常用日期处理函数
查看>>
使用python进行数据的采集 编辑 删除
查看>>
布尔类型及return 严重程度
查看>>
解决springboot程序员的一点小困惑,nginx的反向代理
查看>>
Java虚拟机基本结构的简单记忆
查看>>
hibernate查询返回结果值为实体时接收方法
查看>>
七牛云 ssl免费证书申请
查看>>
基于结构化平均感知机的分词器Java实现
查看>>
比较好的中文分词方案汇总推荐
查看>>
Chrome本地安装Metamask
查看>>
Tomcat介绍 (资源 )
查看>>
【2018.06.28学习笔记】【linux高级知识 17.1-17.5】
查看>>
IPFS是什么?
查看>>