大水题
题目长度似乎与思考难度成反比。。。
直接贴代码了
#include <cmath>
#include <cstdio>
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, m, x;
int a[10] = {0}, *cnt = a + 5;
scanf("%d%d", &n, &m);
for(int i = 1; i <= n; ++i)
{
scanf("%d", &x);
cnt[x]++;
}
int ans = 0;
for(int i = -3; i <= 3; ++i)
if(pow(i, m) > 0)
ans += pow(i, m) * cnt[i];
printf("%d\n", ans);
#ifndef ONLINE_JUDGE
fclose(stdin), fclose(stdout);
#endif
return 0;
}