http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2969
610MS :
View Code
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int t; 6 cin>>t; 7 for(int i = 1; i <= t; i++) 8 { 9 int n; 10 cin>>n; 11 for(int j = 0, num; cin>>num && j< n; j++) 12 { 13 if(j != 0) 14 cout<<" "; 15 cout<<num * (n - j); 16 } 17 cout<<(n == 0 ? "0":"")<<endl; 18 } 19 return 0; 20 }
50MS :
View Code
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int date[1005]; 6 int i,n,m; 7 cin>>n ; 8 while(n--) 9 { 10 cin>>m ; 11 for(i=0;i<=m;i++) 12 cin>>date[i]; 13 if(m==0) cout<<"0" ; 14 else 15 { 16 for(i=0;i<m;i++) 17 { 18 if(i) 19 cout<<" "<<date[i]*(m-i); 20 else cout<<date[i]*(m-i); 21 } 22 } 23 cout<<endl ; 24 } 25 return 0; 26 }