杭电2132
来源:互联网 发布:图书在版编目数据查询 编辑:程序博客网 时间:2024/06/04 23:19
题目描述:
We once did a lot of recursional problem . I think some of them is easy for you and some if hard for you.
Now there is a very easy problem . I think you can AC it.
We can define sum(n) as follow:
if i can be divided exactly by 3 sum(i) = sum(i-1) + i*i*i;else sum(i) = sum(i-1) + i;
Is it very easy ? Please begin to program to AC it..-_-
水题,直接找出通项公式,需要注意的是,输入任意负数退出!!!坑爹,我以为输入-1退出,AC代码:
#include<stdio.h>int main(){__int64 n;while(scanf("%I64d",&n)!=EOF && n>=0){__int64 s=0,t=n/3;s=n*(n+1)/2-3*t*(t+1)/2+t*t*(t+1)*(t+1)/4*27;printf("%I64d\n",s);}}
0 0
- 杭电acm 2132
- 杭电2132
- 杭电2132
- 杭电
- 杭电
- 杭电
- 杭电2132An easy problem
- 杭电 1234 和 杭电 2115
- 杭电2056之Rectangles 杭电
- 杭电ACM1061Rightmost Digit
- 杭电2099 7.11
- 杭电ACM 1003
- 杭电 ACM 2016
- 杭电ACM1466
- 杭电ACM1003
- 杭电ACM1225
- 杭电ACM2023
- 杭电ACM2602
- 重磅推荐,国内国外优秀的素材资源网站
- HTTP和HTTPS详解
- redis pipeline
- TP框架 验证码 分页 无限级分类
- 2016年3月16日,开始自己的博客
- 杭电2132
- 内存泄漏——2.排查方法篇
- iOS 安全攻防系列(五): nm 命令详解
- IBM Security Appscan漏洞--会话标识未更新
- http协议 请求报文和响应报文
- Unity 2d 骨骼动画(官方实践)
- CAP原理和BASE思想
- #include<> 和 #include""的区别
- OC 的常用排序方式