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
 
用普通的做法会超时,只能用公式算n*(4*n*n-1)/3(其中n为第几个数),还有题目明明说好结果在int范围内的,但是必须用__int64才能过,郁闷。。。
 
 #include <stdio.h>

 int main(){
__int64 number;
__int64 n;
__int64 result; while(scanf("%I64d",&number)!=EOF){
n=(number+)/; result=n*(*n*n-)/;
printf("%I64d\n",result); }
return ;
}
 
 

Calculate the formula的更多相关文章

  1. HDOJ(HDU) 2139 Calculate the formula(水题,又一个用JavaAC不了的题目)

    Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) 看到这个时间,我懵逼了... 果然,J ...

  2. HDU 2139 Calculate the formula

    http://acm.hdu.edu.cn/showproblem.php?pid=2139 Problem Description You just need to calculate the su ...

  3. HDU 4342History repeat itself 数学

    C - History repeat itself Time Limit:1000MS     Memory Limit:32768KB      Description Tom took the D ...

  4. 2012 #5 History repeat itself

    History repeat itself Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I6 ...

  5. 【HDU 2855】 Fibonacci Check-up (矩阵乘法)

    Fibonacci Check-up Problem Description Every ALPC has his own alpc-number just like alpc12, alpc55, ...

  6. Fibonacci Check-up

    Fibonacci Check-up Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  7. 【转】朱兆祺教你如何攻破C语言学习、笔试与机试的难点(连载)

    原文网址:http://bbs.elecfans.com/jishu_354666_1_1.html 再过1个月又是一年应届毕业生应聘的高峰期了,为了方便应届毕业生应聘,笔者将大学四年C语言知识及去年 ...

  8. Implementing x / 6 Using Only Bit Manipulations

    This is an interesting question from one of the lab assignments in Introduction to Computer Systems, ...

  9. HDU 4342——History repeat itself——————【数学规律】

    History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

随机推荐

  1. 3.VS2010C++相关文件说明

    stdafx.h说明:stdafx的英文全称为:Standard Application Framework Extensions(标准应用程序框架的扩展).所谓头文件预编译,就是把一个工程(Proj ...

  2. mysql编码详解

    在开发程序的时候,我们使用mysql数据库开发的时候,有时会碰到自己明明输入的是中文,为什么数据库中存储的就是???? 1.在配置Connection URL时,加上?useUnicode=true& ...

  3. Codeforces 597C. Subsequences (树状数组+dp)

    题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长 ...

  4. 关键词权重计算算法:TF-IDF

    TF-IDF(Term Frequency–Inverse Document Frequency)是一种用于资讯检索与文本挖掘的常用加权技术.TF-IDF是一种统计方法,用以评估一字词对于一个文件集或 ...

  5. jquery操作select 的value和text值

    获取select 的text值: $('#testSelect option:selected').text(); 获取select 的value值: $('#testSelect').val(); ...

  6. 查找DOM

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. tab栏切换的特殊效果(类似网易的登陆栏效果)

    代码显示效果如上图所示: 需求说明: 在实际需求中,会遇到这样的情况:不仅是要展示选项卡的内容,而且还有可能在选项卡中需求顾客填写相关内容,而这些内容是顾客如果想了解更深层次的,就会继续填写右边的内容 ...

  8. 开发extjs常用的插件

    Spket是目前支持Ext 2.0最为出色的IDE. 它采用.jsb project file 文件并将继承于基类和所有文档的内容嵌入到生成代码提示的Script doc中.注:不支持配置项的代码提示 ...

  9. 电子图书的编目和OPAC揭示

    摘  要  步入数字图书馆时代,电子资源日益增多,尤其在高校图书馆更加迅猛,怎样将图书馆的电子资源尽可能地整合在OPAC系统的检索功能里,以便更加简便.直观地利用,电子图书的编目已成为重要研究课题.本 ...

  10. Error loading: \Java\jdk1.6.0_35\jre\bin\server\jvm.dll

    先看看错误:complie: [exec] Error loading: D:\Program Files\Java\jdk1.6.0_35\jre\bin\server\jvm.dll [exec] ...