链接http://acm.swust.edu.cn/problem/489/
#include <stdio.h> int main() { int m,n; int temp,i,j; int sum_1,sum_2; int a[100005]; while(scanf("%d%d",&m,&n)!=EOF) { if(m>n) { temp=m; m=n; n=temp; } for(i=m;i<=n;i++) { a[i]=i; } sum_1=sum_2=0; for(i=m;i<=n;i++) { if(a[i]%2==0) { sum_1=sum_1+a[i]*a[i]; } else { sum_2=sum_2+a[i]*a[i]*a[i]; } } printf("%d %d\n",sum_1,sum_2); } return 0; }
时间: 2024-11-08 13:06:56