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 |
晕了 搞不懂题~~~负数不计算在内的吧?如果必须出一个人,要考虑全是负数的情况 哪里错了?帮忙看看#include<stdio.h> #include<math.h> int main() { int n,p,i,a[101],min=-100000,flag=0; double sum=0; scanf("%d%d",&n,&p); for(i=0;i<n;i++) { scanf("%d",&a[i]); if(a[i]>=0) { sum+=pow((double)a[i],(double)p); flag=1; } else if(a[i]>min) min=a[i]; } if(flag) printf("%d\n",(int)sum); else printf("%d\n",(int)pow((double)min,(double)p)); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator