sgu163

来源:互联网 发布:js金沙.com 11 编辑:程序博客网 时间:2024/06/03 07:30

大水题
题目长度似乎与思考难度成反比。。。

直接贴代码了

#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;}
0 0
原创粉丝点击