10177

找到规律就可以写出任意维数的结果

#include<stdio.h>
#include<math.h>
int main()
{
 long n,s1,s2,r2,s3,r3,s4,r4;
 while(scanf("%ld",&n)!=EOF)
 {
  s1=n*(n+1)/2;
  s2=n*(n+1)*(2*n+1)/6;
  s3=s1*s1;
  s4=(long)((pow(n,5)-n)*6+n*(n+1)*(3*n*n-n+1)*5)/30;
  r2=(long)pow(s1,2)-s2;
  r3=(long)pow(s1,3)-s3;
  r4=(long)pow(s1,4)-s4;
  printf("%ld %ld %ld %ld %ld %ld\n",s2,r2,s3,r3,s4,r4);
 }
 return 0;
}

你可能感兴趣的:(10177)