对于每个n所对应的6个数,有以下规律:
a1=∑i^2(i=1…n);
a2=(∑i(i=1…n))^2-a1;
a3=∑i^3(i=1…n);
a4=(∑i(i=1…n))^3-a3;
a5=∑i^4(i=1…n);
a6=(∑i(i=1…n))^4-a5;
#include <iostream>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
long long a1=0,a2=0,a3=0,t=0;
for(long long i=1;i<=n;i++)
{
a1+=i*i;
a2+=i*i*i;
a3+=i*i*i*i;
t+=i;
}
cout<<a1<<" "<<(t*t)-a1<<" "<<a2<<" "<<(t*t*t)-a2
<<" "<<a3<<" "<<(t*t*t*t)-a3<<endl;
}
return 0;
}