ACM ICPC 2002-2003 NEERC, Northern Subregion,居然考这种题……

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//AC
#include <iostream>
using namespace std;
 
inline long power(const long a,const long b)
{
    long t=1;
    for (long i(0);i<b;++i,t*=a);
    return t;
}
 
int main()
{
    long n,p,t,c(0),a;
    cin>>n>>p;
    for (long i(0);i<n;++i)
    {
        cin>>a;
        t=power(a,p);
        if (t>0) c+=t;
    }
    cout<<c<<endl;
    return 0;
}