poj3086

简单题,

View Code
#include <iostream>
#include
<cstdio>
#include
<cstdlib>
#include
<cstring>
using namespace std;

int main()
{
//freopen("D:\\t.txt", "r", stdin);
int t, n;
scanf(
"%d", &t);
for (int i = 0; i < t; i++)
{
scanf(
"%d", &n);
int w = 0, x = 1;
for (int j = 1; j <= n; j++)
{
x
+= j + 1;
w
+= j * x;
}
printf(
"%d %d %d\n", i + 1, n, w);
}
return 0;
}
posted @ 2011-03-13 12:03  金海峰  阅读(192)  评论(0编辑  收藏  举报