Problem Description
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..-_-
 
Input
  The input file contains multilple cases.
  Every cases contain only ont line, every line contains a integer n (n<=100000).
  when n is a negative indicate the end of file.
 
Output
  output the result sum(n).
 
Sample Input
1
2
3
-1
 
Sample Output
1
3
30

#include<iostream>
using namespace std;
int main()
{
    __int64 i,n,a[100001];
    a[0]=0;
    for(i=1;i!=100001;++i)
    {
        if(i%3==0)
            a[i]=a[i-1]+i*i*i;//////  i*i*i的过程中 当I等于99999的时候 用int去存的话 有溢出(这里是吧i*i*i的值放在一个int的空间里面 然后再进行赋值运算  要尤其注意)
        else
            a[i]=a[i-1]+i;
    }
    while(cin>>n&&n>=0)
    {
        cout<<a[n]<<endl;
    }
    return 0;
}

hdu 2132... 被基本问题考住了。。的更多相关文章

  1. HDU 2132 An easy problem

    http://acm.hdu.edu.cn/showproblem.php?pid=2132 Problem Description We once did a lot of recursional ...

  2. HDU 1042 N! 參考代码

    HDU 1042 N! 题意:给定整数N(0 ≤ N ≤ 10000), 求 N! (题目链接) #include <iostream> using namespace std; //每一 ...

  3. HDOJ(HDU) 2132 An easy problem

    Problem Description We once did a lot of recursional problem . I think some of them is easy for you ...

  4. 【hdu多校联考第二场】Odd Shops

    Description 这道题的题意是这道难读,大概就是给你n个商店,每个商店的重量为i的商品用ai表示,对于任意商店的a数列都是相同的,重量的范围为[1,10] 求购买方案总数为奇数的重量一共有多少 ...

  5. hdu 4612 Warm up(缩点+树上最长链)

    本来就是自己负责图论,结果水了= = 题目其实很裸,就是求桥的数量,只是要新加上一条边罢了.做法:先缩点.再在树上搜最长链(第一场多校的hdu 4607Park Visit就考了最长链,小样,套个马甲 ...

  6. SPFA

    SPFA算法用来求单源最短路.可以处理任何有解的情况. 先建一个数组\(dist_x = 起点到x的最短路长度\),当\(x=起点\)时为0,当x和起点不通时为INF(本题中为\(2^31-1\)). ...

  7. 最短路洛谷P2384

    题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你100000000000000000000000000000000000%10金币w ...

  8. 20155205 2016-2017-2《Java程序设计》课程总结

    20155205 2016-2017-2<Java程序设计>课程总结 目录 一.每周作业链接汇总 二.实验报告链接汇总 三.博客中的经验与收获 - 自认为写得最好一篇博客是?为什么? - ...

  9. P2384 最短路

    题目背景 狗哥做烂了最短路,突然机智的考了Bosh一道,没想到把Bosh考住了...你能帮Bosh解决吗? 他会给你100000000000000000000000000000000000%10金币w ...

随机推荐

  1. matplotlib显示黑白灰度图像颜色设置

    对于黑白灰度图像(矩阵) 1. 默认使用伪彩色拉升 2 cmap参数为 binary,可能导致颜色反转 3. cmap = gray,same color as origin, that is, wh ...

  2. DevOps Scrum Agile Tech Debt

    从实践中长出的 DevOps 大树 - 服务管理 - CIO时代—新技术.新商业.新管理http://www.hunnatv.com/glfw/145411.html Nexus规模化Scrum框架h ...

  3. 为什么在MySQL数据库中无法创建外键?(MyISAM和InnoDB详解)

    问题描述:为什么在MySQL数据库中不能创建外键,尝试了很多次,既没有报错,也没有显示创建成功,真实奇了怪,这是为什么呢? 问题解决:通过查找资料,每次在MySQL数据库中创建表时默认的情况是这样的: ...

  4. ISCSI多路径配置(二)

    搭建iscsi存储系统(一) (1).配置ISCSI多路径实现磁盘挂载高可用 如果存储服务器到交换机只有一条线路的时候,那么一条线路出现故障,整个就没法使用了,所以多线路可以解决这个问题,避免单点故障 ...

  5. NativeExcel3使用示例

    除了XLSReadWriteII5,还有个NativeExcel也是比较好的操作excel的组件,现将NativeExcel3的使用示例写一下,以下是代码和生成的excel表格的效果: procedu ...

  6. docker容器中解决出现:^H^H^H^H

    docker容器中解决出现:^H^H^H^H 环境:docker容器是debain系统 解决: 把stty erase ^H 添加到.bash_profile中 vim /etc/profile st ...

  7. C#操作IIS程序池及站点的创建配置实现代码

    首先要对Microsoft.Web.Administration进行引用,它主要是用来操作IIS7: using System.DirectoryServices;using Microsoft.We ...

  8. 【Leetcode_easy】1033. Moving Stones Until Consecutive

    problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...

  9. K8S - 容器编排工具Kubernetes简介

    1 - Kubernetes Kubernetes(简称K8s,用8代替8个字符"ubernete")是Google开源的一个容器编排引擎. 目前最为广泛且流行的容器编排调度系统, ...

  10. CentOS 6 新装服务器部署流程

    1.设置时区 rm -f /etc/localtime cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2.配置内网IP (如果是外网IP,li ...