1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 #include<math.h> 5 #define MAXN 200 6 using namespace std; 7 8 int a[MAXN]; 9 int num2; 10 int num1; 11 int compare(const void * i,const void * j); 12 void op(int & a); 13 int main() 14 { 15 int tem; 16 int i; 17 int j; 18 int sum; 19 sum = 0; 20 j = 0; 21 cin>>num1; 22 cin>>num2; 23 for(i = 0; i < num1; ++ i) 24 { 25 cin>>a[i]; 26 } 27 for_each(a,a+num1,op); 28 for(i = 0; i < num1; ++ i) 29 { 30 if(a[i] > 0) 31 { 32 sum += a[i]; 33 } 34 } 35 cout<<sum<<endl; 36 } 37 void op(int & a) 38 { 39 a = (int)pow(long double(a),num2); 40 }
时间: 2024-10-27 18:42:13