zoukankan      html  css  js  c++  java
  • hdu 2114 Calculate S(n)

    hdu 2114 Calculate S(n)

    Problem DescriptionCalculate S(n).

    S(n)=13+23 +33 +......+n3 .  InputEach line will contain one integer N(1 < n < 1000000000). Process to end of file.  OutputFor each case, output the last four dights of S(N) in one line.
      Sample Input12  Sample Output00010009

    以下代码对支持longlong的编译器可通过:

    #include<iostream>
    using namespace std;
    int main()
    {
     long long n,i,m;
     while(cin>>n)
     {
      n=n%10000;
      m=n*(n+1)/2%10000;            //数学公式:1^3+2^3+3^3+……+n^3=[n(n+1)/2]^2 
      m=m*m%10000;
      printf("%04d\n",m);
     }
     return 0;
    }

  • 相关阅读:
    JSP第三章
    JSP第二章
    JSP第一章
    异常
    七种设计原则
    非泛型集合
    .NET第一章
    航班预定系统
    JSP数据交互(二)
    JSP数据交互(一)
  • 原文地址:https://www.cnblogs.com/crazyapple/p/2999499.html
Copyright © 2011-2022 走看看