| ||||||||||
| 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 | |||||||||
sort函数我是不是用错了?#include<stdio.h>
#include<algorithm>
bool cmp(int i,int j)
{
return i>j;
}
int power(int i,int e)
{
int r=1;
for(int j=0;j<e;j++)
r*=i;
return r;
}
void main()
{
int n,e,r[105],t,total=0;
scanf("%d",&n);
scanf("%d",&e);
for(int i=0;i<n;i++){
scanf("%d",&t);
r[i]=power(t,e);
}
std::sort(r,r+n,cmp);
i=0;
while(r[i]>0) total+=r[i++];
printf("%d\n",total);
}
为什么WA,不用sort就能AC
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator