Sum of squares and cubes and

Source: Internet
Author: User

Problem description

Given a continuous integer, calculate the sum of squares of all even numbers and the sum of cubes of all odd numbers.

 

Input

The input data contains multiple groups of test instances. Each group of test instances contains a row consisting of two integers, M and N.

 

Output

For each group of input data, the output line should contain two integers x and y, indicating the sum of squares of all the even numbers in the continuous integer of the segment and the sum of all the odd numbers of cubes and.

You can think that a 32-bit integer is enough to save the result.

 

Sample Input

1 3

2 5

 

Sample output

4 28

20 152

 

 1 #include <stdio.h> 2   3 int main(){ 4     int a; 5     int b; 6     int i; 7     int temp; 8     int oushu_sum; 9     int jishu_sum;10      11     while((scanf("%d%d",&a,&b))!=EOF){12         oushu_sum=0;13         jishu_sum=0;14          15         if(a>b){16             temp=a;17             a=b;18             b=temp;19         }20          21         for(i=a;i<=b;i++){22             if(i%2==0){23                 oushu_sum+=(i*i);24             }25              26             else27                 jishu_sum+=(i*i*i);28         }29          30         printf("%d %d\n",oushu_sum,jishu_sum);31     }32      33     return 0;34 }

 

Sum of squares and cubes and

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.