![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h> 2 #include<math.h> 3 int son[ 1005 ]; 4 int main(){ 5 int n,m; 6 while( scanf("%d%d",&n,&m)==2 ){ 7 for( int i=0;i<n;i++ ) 8 scanf("%d",&son[i]); 9 int sum = 0; 10 if( m%2==1 ){ 11 for( int i=0;i<n;i++ ){ 12 if( son[i]>0 ){ 13 sum += (int)pow( 1.0*son[i],m ); 14 } 15 } 16 } 17 else{ 18 for( int i=0;i<n;i++ ){ 19 sum += (int)pow( 1.0*son[i],m ); 20 } 21 } 22 printf("%d ",sum); 23 } 24 return 0; 25 }
没什么好说的。。