(Hdu simple question 128) squared sum with cubic and (ask for an interval of cubic sum and sum of squares)

Source: Internet
Author: User

Topic:

Sum of squares and cubic andTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 108212 Accepted Submission (s): 34915


Problem description Given a continuous number of integers, the sum of all the even squares of all of them, and all the odd cubes.

Input data contains multiple sets of test instances, each containing a row consisting of two integers m and N.
Output for each set of input data, one line should consist of two integers x and y, representing the sum of all the even squares of the consecutive integers in that segment and all the odd cubic and.
You can assume that a 32-bit integer is sufficient to save the result.
Sample Input

1 32 5

Sample Output
4 2820 152

Authorlcy
SOURCEC Language Programming Exercises (I.)


Topic Analysis:

Simple question.


The code is as follows:


/* * c.cpp * *  Created on:2015 March 20 *      author:administrator * * #include <iostream> #include <cstdio># Include <cmath>using namespace Std;int main () {int a,b;while (scanf ("%d%d", &a,&b)!=eof) {double Ans_ji = 0; Double Ans_ou = 0;int i;//The problem needs to be noted is to consider the case of B<a if (b < a) {swap (A, a);} for (i = A; I <= b; ++i) {if (i% 2 = = 1) {Ans_ji + = POW (i+0.0,3);} Else{ans_ou + = POW (i+0.0,2);}} printf ("%d%d\n", (int) ans_ou, (int) ans_ji);} return 0;}




(Hdu simple question 128) squared sum with cubic and (ask for an interval of cubic sum and sum of squares)

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.