杭电2007 平方和与立方和

//题目很简单

 

#include<stdio.h>
int main()
{   
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        int i,temp;
        int odd=0,even=0;
        if(a>b)
        {
            temp=a;
            a=b;
            b=temp;
        }
        for(i=a;i<=b;i++)
        {
            if(i%2==1)
            {
                odd=odd+i*i*i;
            }
            else
            {
                even=even+i*i;
            }
        }
        printf("%d %d\n",even,odd);
    }
    return 0;
}

posted @ 2012-04-12 17:59  加拿大小哥哥  阅读(197)  评论(0编辑  收藏  举报