题目大意:输入N,求N为边长的正方形中,以一单位长度画线,有多少的正方形,多少个长方形,N为边长的正方体中,以一单位长度画线,有多少个正方体,多少个长方体,N为变成的四维图像上,有多少个正方超体,长方超体。

解题思路:正方的数量为1~N的pow(i,维度)之和。矩形的数量为pow((N*N-1)/2, 维度+1)。长方的数量为正方-矩形。

ac代码:

#include <iostream>
#include <cmath>
using namespace std;
int n;
long long t1, t2, t3, t4, t5, t6;
int main()
{
while (scanf("%d", &n)!=EOF){
t1 = t2 = t3 = t4 = t5 = t6 = 0;
for (int i=1; i<=n; i++){
t1 += pow(i, 2);
t3 += pow(i, 3);
t5 += pow(i, 4);
}
t2 = pow(n * (n+1)/2, 2);
t4 = pow(n * (n+1)/2, 3);
t6 = pow(n * (n+1)/2, 4);
printf("%lld %lld %lld %lld %lld %lld\n", t1, t2-t1, t3, t4-t3, t5, t6-t5);
}
return 0;
}