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