Hangzhou Electric 5053 The Sum of the cube (for the cubic and in the interval) to play the table method

Source: Internet
Author: User

Descriptiona range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range. Inputthe first line of the input was T (1 <= t <=), which stands for the number of test cases you need to solve.
Each case of input is a pair of integer A, a (0 < a <= B <= 10000), representing the range[a,b]. Outputfor, print a line ' case #t: ' (without quotes, t means the index of the test case) at the beginning. Then output the Answer–sum the cube of the integers in the range. Sample Input21 5 Sample Outputcase #1:36Case #2:224
1#include <cstdio>2__int64 a[1000000]={0,1};3 intMain ()4 {5      for(__int64 i=1; i<=1000000; i++)6     {7a[i]=a[i-1]+i*i*i;8     }9__int64 t,k=0;;Tenscanf"%i64d",&t); One      while(t--) A     { - __int64 m,n; -scanf"%i64d%i64d",&m,&n); theprintf"Case #%i64d:%i64d\n", ++k,a[n]-a[m-1]); -     } -}

Hangzhou Electric 5053 The Sum of the cube (for the cubic and in the interval) to play the table method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.