杭电2139
来源:互联网 发布:全民奇迹翅膀进阶数据 编辑:程序博客网 时间:2024/06/05 11:45
Calculate the formula
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7770 Accepted Submission(s): 2393
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
Author
wangye
Source
HDU 2007-11 Programming Contest_WarmUp
水题……打表
#include <iostream>using namespace std;__int64 x[10000];int main(){int m,n,i;x[1]=1;for(i=3;i<=10000;i++){x[i]=x[i-2]+i*i;}while (cin>>n){printf("%I64d\n",x[n]);}return 0;}
0 0
- 杭电2139
- 杭电
- 杭电
- 杭电
- 杭电acm 2139 Calculate the formula
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 杭电ACM2023
- 杭电ACM2602
- 杭电ACM2955
- 杭电ACM3198
- Android开发学习笔记七 ImageCacheLoader
- Thieves (hdu 3491 拆点 最小割)
- 大概CentOS7 安装LAMP的步骤
- exchange2003内部之间不能收发邮件
- 04-树8. Complete Binary Search Tree (30)
- 杭电2139
- 访问者模式
- HDU 1269 迷宫城堡 (有向图的强连通分量)
- [编程之美]写一个函数,返回一个数组中所有元素被第一个元素除的结果
- python学习之模块添加
- java常用设计模式
- Exchange2003遇到退信垃圾邮件攻击
- C语言学习笔记
- [AD]使用DCDiag工具测试域控制器的网络连接和DNS解析