#include <iostream> #include <cstdio> #include <cmath> using namespace std; int cube(int n) { return n * n * n; } int square(int n) { return n * n; } int main() { int m, n; while(~scanf("%d %d", &m, &n)) { if(m > n) swap(m, n); int odd_sum = 0, even_sum = 0; for(int i = m; i <= n; ++ i) { if(i % 2 == 1) { odd_sum += cube(i); } else { even_sum += square(i); } } printf("%d %d\n", even_sum, odd_sum); } return 0; }
题目没有说明m和n的大小, 自己要进行一次判断