Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:求助!!!sos(why wa!)【附代码】In Reply To:求助!!!sos(why wa!)【附代码】 Posted by:chmx at 2008-05-15 10:33:33 #include<stdio.h> #define M 305 int main() { int a[M]; int T,i,ans,n; int count=1; a[0]=0; for(i=1;i<=301;i++) a[i]=a[i-1]+i; scanf("%d",&T); while(T--) { scanf("%d",&n); ans=0; for(i=1;i<=n;i++) ans+=i*a[i+1]; printf("%d %d %d\n",count++,n,ans); } return 0; } /* 4 3 4 5 10 1 3 45 2 4 105 3 5 210 4 10 2145 */ Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator