题意比较难理解,第二个数字是指数,从数列中选择任意多个,使得他们每个求幂再求和最大。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
int main()
{
//freopen("t.txt", "r", stdin);
int n, p;
scanf("%d%d", &n, &p);
int ans = 0;
for (int i = 0; i < n; i++)
{
int a;
scanf("%d", &a);
a = pow(a, p);
if (a > 0)
ans += a;
}
printf("%d\n", ans);
return 0;
}