HDU-#5053 the Sum of Cube
2014-09-27 18:20
369 查看
题目大意:求[a,b]之间每个数的立方和。
解题思路:签到题,直接求解会WA的,所以直接用公式求解,为:1^3+2^3+3^3+……+n^3=(n*(n+1))^2,详见code。
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=5053
code:
解题思路:签到题,直接求解会WA的,所以直接用公式求解,为:1^3+2^3+3^3+……+n^3=(n*(n+1))^2,详见code。
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=5053
code:
#include <iostream> #include <cstdio> #include <cmath> using namespace std; #define ll __int64 int t,a,b; ll cube(ll m){ return (m*(m+1)/2)*(m*(m+1)/2); } int main(){ int cases=0; scanf("%d",&t); while(t--){ scanf("%d%d",&a,&b); printf("Case #%d: %I64d\n",++cases,cube(b)-cube(a-1)); } return 0; }
相关文章推荐
- hdu 5053 the Sum of Cube---2014acm上海赛区网络赛
- 【水题】HDU 5053 the Sum of Cube
- hdu----(5053)the Sum of Cube(签到题,水体)
- HDU-5053-the Sum of Cube【打表】
- hdu 5053 the Sum of Cube(水)
- HDU 5053 the Sum of Cube(数学求立方和)
- hdu 5053 the Sum of Cube(上海网络赛)
- hdu 5053 the Sum of Cube(上海网络赛)
- hdu 5053(2014上海网赛1012) the Sum of Cube
- HDU - 5053 the Sum of Cube
- HDU--5053 the Sum of Cube
- 【HDU - 5053】the sum of cube
- HDU-5053 the Sum of Cube
- 【hdu 5053】the Sum of Cube
- hdu 5053 the Sum of Cube 水题 2014 ACM/ICPC Asia Regional Shanghai Online
- 【水题】HDU 5053 the Sum of Cube
- Hdu-5053 the Sum of Cube(水题)
- HDU 5053 the Sum of Cube 2014 ACM/ICPC Asia Regional Shanghai Online
- hdu 5053 the Sum of Cube 水题
- HDOJ 5053 the Sum of Cube (立方和)