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 WA?谁能帮我看看……

Posted by fantashy at 2010-06-06 01:21:00 on Problem 1068 and last updated at 2010-06-06 13:37:55
#include <stdio.h>
int main()
{
	int n,m,d[100],c[100],r[100];
	int i,j,t;
	int s=2;
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d",&m);
		for(j=0;j<m;j++)
		{
			scanf("%d",&d[j]);
		}
		c[0]=d[0];
		for(j=1;j<m;j++)
		{
			c[j]=d[j]-d[j-1];
		}
		for(j=0;j<m;j++)
		{
			if(c[j]!=0)
				r[j]=1;
			else {
				if(d[j]!=0)
				{
				for(t=j;c[t-1]==0&&t>0;t--)
					s++;
				t=j;
				while(c[t-1]<s&&t>0)
					t--;
				if(t!=0)
					r[j]=j-t+2;
				else r[j]=0;
				}
				else r[j]=0;
			}
			s=2;
			printf("%d ",r[j]);
		}
		printf("\n");
	}
	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