Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

牛人们救救我!怎么老是输出1!(附原代码)

Posted by jubo at 2007-05-04 11:22:24 on Problem 2487
#include<stdio.h>
#include<stdlib.h>

int main()
{
   int a[1002];
   int n,i,j,need,sum,b,q,zb,flag;
        scanf("%d",&n);
        for(i=0;i<n;i++)
            {
             sum=0;q=0;flag=0;zb=1;b=0;
             scanf("%d%d",&need,&a[0]);
             for(j=1;j<=a[0];j++)scanf("%d",&a[j]);
             for(j=1;j<=a[0];j++)
                 {for(j=1;j<=a[0];j++) if(b<=a[j]){b=a[j];zb=j;}
                  a[zb]=0;
                  sum+=b;
                  q++;
                  /**/if(sum>need){printf("Scenario #%d:\n%d\n\n",i+1,q);flag=1;break;}
                 }
             if(flag==0) printf("Scenario #%d:\nimpossible\n\n",i+1);
             }
    system("PAUSE");
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator