HDU_2007

 1 /**
 2 *注意:输入的两个数字的大小并不确定
 3 */
 4 #include <iostream>
 5 #include <stdio.h>
 6 #include <string.h>
 7 #include <math.h>
 8 #include <stdlib.h>
 9 
10 using namespace std;
11 
12 int main()
13 {
14     int i,res1;
15     int res2,x,y;
16     while(~scanf("%d%d",&x,&y))
17     {
18         res1 = 0;
19         res2 = 0;
20         if(x > y)
21          {
22              i = x;
23              x = y;
24              y = i;
25          }
26         for(i = x ;i <= y;i ++)
27         {
28 
29            // scanf("%d",&num);
30             if(i % 2 != 0)
31             {
32                 res1 += i * i * i;
33             }else{
34                 res2 += i * i;
35             }
36         }
37         printf("%d %d
",res2,res1);
38     }
39     //cout << "Hello world!" << endl;
40     return 0;
41 }
原文地址:https://www.cnblogs.com/banshaohuan/p/4536322.html