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

WHY?WHY?WHY?

Posted by hubo430 at 2005-11-29 16:55:56 on Problem 1323
这样可以过:
#include<stdio.h>
#include<iostream.h>
int main()
{
    int m,n,number=0;
    while(scanf("%d%d",&m,&n)==2)
    {if(m==0&&n==0) break;number++;
    int i,i1,a[1001],t[50],num=0;
    for(i=1;i<=m*n;i++) a[i]=1;
    for(i=0;i<n;i++) {scanf("%d",&t[i]);a[t[i]]=0;}

    for(i=0;i<n;i++)
    {if(t[i]==m*n) num++;
    else {
        for(i1=t[i]+1;i1<=m*n;i1++) 
            if(a[i1]==1) {a[i1]=0;break;}
            if(i1==m*n+1) num++;
        }
    }
    printf("Case %d: %d\n",number,num);
    }
    return 0;
}
这样就不可以过了:
#include<stdio.h>
#include<iostream.h>
int main()
{
    int m,n,number=0;
    while(scanf("%d%d",&m,&n)==2)
    {if(m==0&&n==0) break;number++;
    int i,i1,a[1001],t[50],num=0;
    for(i=1;i<=m*n;i++) a[i]=1;
    for(i=0;i<n;i++) {cin>>t[i];a[t[i]]=0;}

    for(i=0;i<n;i++)
    {if(t[i]==m*n) num++;
    else {
        for(i1=t[i]+1;i1<=m*n;i1++) 
            if(a[i1]==1) {a[i1]=0;break;}
            if(i1==m*n+1) num++;
        }
    }
    printf("Case %d: %d\n",number,num);
    }
    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