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

为什么WA呢?程序如下

Posted by yiyiyi4321 at 2005-08-04 18:09:01 on Problem 2527
#include<stdio.h>
main()
{int i,j,n,k;
 long a[10001];
 while(scanf("%d%d",&n,&k))
 {if(n==-1&&k==-1)break;
  for(i=0;i<=n;i++)
   scanf("%ld",&a[i]);
  if(k==0){printf("%d\n",0);
	   continue;}
  for(i=0;i<=n-k;i++)
  {if(a[i]==0)i++;
   if(i>n-k)break;
   a[i+k]-=a[i];
   a[i]=0;
  }
  for(j=i;j<=n;j++)
   {printf("%ld",a[j]);
    if(j<n)printf(" ");
    else printf("\n");
   }
 }
}

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