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 Alexande at 2006-03-22 22:35:16 on Problem 2527
#include <stdio.h>
#define Max 10002
long Coe[Max];

void main()
{
  int i,j,n,k,end;
  scanf("%d %d",&n,&k);
  while(1)
  {
    if(n==-1&&k==-1)
		break;
	for(i=0;i<=n;i++)
		Coe[i]=0;
    for(i=0;i<=n;i++)
		scanf("%ld",&Coe[i]);
	if(k==0)
		printf("0\n");
	else
	{
	  j=n;
      while(j>=k)
	  {
	    Coe[j-k]=Coe[j-k]-Coe[j];
	    Coe[j]=0;
	    j--;
	  }
      end=0;
	  for(i=k-1;i>0;i--)
		if(Coe[i]!=0)
		{
		   end=i;
		   break;
		}
      printf("%ld ",Coe[0]);
	  if(end!=0)
	  {
	   for(i=1;i<=end;i++)
		  printf("%ld ",Coe[i]);
	  }
	  printf("\n");
	}
	scanf("%d %d",&n,&k);
  }
}

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