编程介的小学生 2019-06-02 09:57 采纳率: 20.5%
浏览 396

三次方的求和运算的算法的问题,运用C语言的程序的编写的技术的过程怎么实现呢

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

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 maixpy训练模型,模型训练好了以后,开发板通电会报错,不知道是什么问题
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 有没有帮写代码做实验仿真的
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥30 vmware exsi重置后登不上
    • ¥15 c++头文件不能识别CDialog
    • ¥15 Excel发现不可读取的内容