标签:style blog io color ar os sp for strong
W(n) = SUM[k = 1…n; k * T(k + 1)]
1 #include <stdio.h> 2 3 int sum(int n); 4 5 int main(){ 6 int T; 7 int n; 8 int i; 9 int result; 10 int time; 11 12 time=1; 13 14 scanf("%d",&T); 15 16 while(T--){ 17 scanf("%d",&n); 18 19 result=0; 20 for(i=1;i<=n;i++) 21 result+=i*sum(i+1); 22 23 printf("%d %d %d\n",time,n,result); 24 time++; 25 } 26 27 return 0; 28 } 29 30 int sum(int n){ 31 int i; 32 int result; 33 34 result=0; 35 for(i=1;i<=n;i++) 36 result+=i; 37 38 return result; 39 }
标签:style blog io color ar os sp for strong
原文地址:http://www.cnblogs.com/zqxLonely/p/4097970.html