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 |
为什么总是wa?疑惑!大街帮帮忙看一小下。:[#include <iostream> using namespace std; int main() { int sceNum,staNum,perNum,sum,d; int result=0; int i=0; int j=0; int U[1000]; int V[1000]; while(cin>>sceNum) { if(!sceNum) break; for(int i=0;i<sceNum;i++)//输入该组需要邮票数和人数 { cin>>staNum>>perNum; for(int j=0;j<perNum;j++)//将每人邮票数录入数组 cin>>U[j]; //冒泡排序 for(int a=0;a<perNum;a++) for(int b=a+1;b<perNum;b++) { if(U[a]<U[b]) { int temp=U[a]; U[a]=U[b]; U[b]=temp; } } //求和 sum=result=d=0; while (sum<staNum) { sum+=U[d]; d++; if(sum>=staNum||d>perNum) break; } V[i]=d; } for(i=0;i<sceNum;i++) { cout<<"Scenario #"<<i+1<<':'<<endl; if(V[i]<=perNum) cout<<V[i]<<endl<<endl; else cout<<"impossible"<<endl<<endl; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator