Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
200題記念#include<stdio.h> #include<math.h> #include<algorithm> int main(){ int a; int b; int c[100]; scanf("%d%d",&a,&b); for(int i=0;i<a;i++){ scanf("%d",c+i); } std::sort(c,c+a); int ans=0; if(b%2){ for(int i=a-1;i>=0;i--){ if(c[i]<0)break; else ans+=(int)pow((double)c[i],(double)b); } }else{ for(int i=0;i<a;i++)ans+=(int)pow((double)c[i],(double)b); } printf("%d\n",ans); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator