#UVa:10302-Summation of Polynomials

灆洢 2015-01-04 00:45:59

利用公式解即可,注意範圍會超過int的限制。

C++(0.019)

/*******************************************************/
/* UVa 10302 Summation of Polynomials                  */
/* Author: Maplewing [at] knightzone.studio            */
/* Version: 2015/01/03                                 */
/*******************************************************/
#include <iostream>
#include <cstdio>
using namespace std;

int main(){
  long long int x;
  while( scanf("%lld", &x) != EOF ){
    printf("%lld\n", x*x*(x+1)*(x+1)/4 );
  }

  return 0;
}

發表迴響

這個網站採用 Akismet 服務減少垃圾留言。進一步瞭解 Akismet 如何處理網站訪客的留言資料