HDU2114 Calculate S(n)【数学】

Calculate S(n)

Time Limit: 10000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 8423    Accepted Submission(s): 3060

Problem Description

Calculate S(n).

S(n)=13+23 +33 +......+n3 .

Input

Each line will contain one integer N(1 < n < 1000000000). Process to end of file.

Output

For each case, output the last four dights of S(N) in one line.

Sample Input

1

2

Sample Output

0001

0009

Author

天邪

Source

HDU 2007-10 Programming Contest_WarmUp

题目大意:计算1~N的立方和

思路:1~N的立方和公式为S(N) = 1^3 + 2^3 + 3^3 + … + N^3 = N^2*(N+1)^2/4。

然后题目要求后四位,取余即可。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;

int main()
{
    __int64 N,ans;
    while(cin >> N)
    {
        N %= 10000;
        ans = (N*(N+1)/2)%10000 * (N*(N+1)/2)%10000;
        printf("%04I64d\n",ans);
    }

    return 0;
}
时间: 2024-08-10 19:53:25

HDU2114 Calculate S(n)【数学】的相关文章

ZOJ 3179 Calculate With Abacus(数学啊 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3220 Abacus is a manual computing device consisting of a frame holding parallel rods strung with movable beads. How to calculate with Abacus: Each rod is divided into two parts by the se

数学词汇

算数-整数 integer consecutive integer positive whole integer negative whole integer even / even integer odd /odd integer real number divisor remainder composite number quotient prime numberprime factorsuccessive adj 连续的score n 二十consecutive adj 连续的sonsta

杭电ACM 二 数学求模

Font Size: ← → Problem Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). Input The input consists of multiple test cases. Ea

HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathys

数学之路-python计算实战(22)-机器视觉-sobel非线性滤波

sobel非线性滤波,采用梯度模的近似方式 Sobel Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. C++: void Sobel(InputArray src, OutputArray dst, int ddepth, int dx, int dy, intksize=3, double scale=1, double delta=0, int

ZOJ3329-One Person Game(概率DP求数学期望)

One Person Game Time Limit: 1 Second      Memory Limit: 32768 KB      Special Judge There is a very simple and interesting one-person game. You have 3 dice, namelyDie1, Die2 and Die3. Die1 hasK1 faces. Die2 has K2 faces.Die3 has K3 faces. All the dic

HDU 5073 Galaxy(Anshan 2014)(数学推导,贪婪)

Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 556    Accepted Submission(s): 127 Special Judge Problem Description Good news for us: to release the financial pressure, the government

丘成桐大学生数学竞赛2010年分析与方程个人赛试题参考解答

1 (1)Let {xk}nk=1?(0,π) , and define x=1n∑k=1nxi. Show that ∏k=1nsinxkxk≤(sinxx)n. Proof. Direct computations show (lnsinxx)′′=(lnsinx?lnx)′′=?1sin2x+1x2<0, for all x∈(0,π) . Thus lnsinxx is a concave function in (0,π) . Jensen's inequality then yiel

Essential Calculate计算控件全面介绍及下载

Essential Calculate控件是一款强大的计算引擎,内嵌150多种计算公式,为商业对象添加扩展的计算支持,在没有Excel的情况下,完全可以与Essential XlsIO整合,支持进行像Excel一样的计算. 具体功能: 支持自动或手动计算 仅仅需要单个命令就可以对整个文本框或下拉列表框进行计算 使用CalcDataGrid类可以很容易地为Windows Forms data grid添加计算支持 广泛的计算公式,多种标准的数学.金融公式 支持为任何自定义对象添加计算支持 根据其他