hdu2132 An easy problem
来源:互联网 发布:stm32cubemx软件下载 编辑:程序博客网 时间:2024/05/18 07:11
#include <stdio.h>
#include <string.h>
int main()
{
int n,i;
long long a[100005];
a[0]=0;
a[1]=1;
for(i=2;i<100002;i++)
{
if(i%3==0) a[i]=a[i-1]+i*i*i;
else a[i]=a[i-1]+i;
}
while(~scanf("%d",&n)&&(n>=0))
{
printf("%I64d\n",a[n]);
}
return 0;
#include <string.h>
int main()
{
int n,i;
long long a[100005];
a[0]=0;
a[1]=1;
for(i=2;i<100002;i++)
{
if(i%3==0) a[i]=a[i-1]+i*i*i;
else a[i]=a[i-1]+i;
}
while(~scanf("%d",&n)&&(n>=0))
{
printf("%I64d\n",a[n]);
}
return 0;
}
心得:本以为轻轻地水一下,结果__int64不能用,必须用long long,还有括号忘了加WA了,还有迭代应该放在while外面,两天没做题太烂了。。。好歹赶上博客进度
0 0
- hdu2132 An easy problem
- HDU2132 An easy problem 【Java】
- HDU2132 An easy problem【水题】
- hdu2132 An easy problem(C语言)
- An Easy Problem
- 2055 An easy problem
- An Easy Problem!
- An Easy Problem!
- poj2826 An Easy Problem?!
- HDOJ2055 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- hdu2601 An easy problem
- An Easy Problem
- hdu-An Easy Problem
- HDU_2055 An easy problem
- HDU_2123 An easy problem
- B - An easy problem
- Hibernate反向工程使用心得
- Android中windowSoftInputMode属性详解
- js2次学习----常用知识点总结
- 自学QT之获取目录下的全部文件并且添加到tablev中
- css选择器
- hdu2132 An easy problem
- spring mvc拦截器
- Expression Add Operators
- VS2008配置OpenGL
- poj 1094
- 【IOS 开发学习总结-OC-46】★ios开发之UI控件——UIProgressView 与 UISlider(另:可拉伸图片)
- 从机器学习谈起
- 第二阶段 软件功能测试过程
- Visual Studio 命令别名