天天看點

HDU 2007 - 平方和 和 立方和

題目連結:http://acm.hdu.edu.cn/showproblem.php?pid=2007

#include <stdio.h>

int main(void)
{
    unsigned int m, n, i, x, y;

    while (scanf("%u%u", &m, &n) != EOF)
    {
        if (m > n)
        {
            i = n;
            n = m;
            m = i;
        }
        x = y = 0;
        for (i = m ; i <= n ; i++)
            (i & 1) ? (y += i*i*i) : (x += i*i);
        printf("%u %u\n", x, y);
    }

    return 0;
}
			 			
 
           
php