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. 转】从源代码剖析Mahout推荐引擎

    原博文出自于: http://blog.fens.me/mahout-recommend-engine/ 感谢! 从源代码剖析Mahout推荐引擎 Hadoop家族系列文章,主要介绍Hadoop家族产 ...

  2. C#.Net 导出Excel 之单元格 相关设置

    range.NumberFormatLocal = "@";     //设置单元格格式为文本range = (Range)worksheet.get_Range("A1 ...

  3. 主题敏感词PageRank

    [主题敏感词PageRank] PageRank忽略了主题相关性,导致结果的相关性和主题性降低,对于不同的用户,甚至有很大的差别.例如,当搜索“苹果”时,一个数码爱好者可能是想要看 iphone 的信 ...

  4. Azure linux centos 默认登陆账号是什么?

    什么?刚创建的linux虚拟机账号忘记了? 不要急,往下看!! Azure为我们考虑好了,默认创建centos 系统时,默认账号是azureuser,这个账号是非root权限的. 很多人在创建的时候容 ...

  5. POJ 1556 The Doors(线段交+最短路)

    The Doors Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5210   Accepted: 2124 Descrip ...

  6. java之四大皆空

    SE中的所有空的情况: 第一空:定义变量,变量没有值不能使用,不能打印 public class DiDaJieKong01 { public static void main(String[] ar ...

  7. getConnection 区别

    1. 这是一个接口 package javax.sql; DataSource.class /** * <p>Attempts to establish a connection with ...

  8. UVa 10004:Bicoloring

    这道题要我们判断所给图是否可以用两种颜色进行染色,即"二染色“.已知所给图一定是强连通图. 分析之: 若图中无回路,则该图是一棵树,一定可以二染色. 若图中有回路,但回路有偶数个节点,仍然可 ...

  9. websocket的php测试demo

    <?php class WS { var $master; var $sockets = array(); var $debug = false; var $handshake = false; ...

  10. Custom ReadOnlyProperty【PluraSight】

    Limited functionality: Not settable No data binding No validation No animation No Inheritance When t ...