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 1 9 1 1 2 1 1 的情况,why wrong ???

Posted by john1114 at 2009-01-20 18:09:55 on Problem 3125
#include<stdio.h>
#include<string.h>
int main()
{
	int t,i,j,a[101],n,m,s;
	scanf("%d",&t);
	while(t--)
	{
		s=1;
		memset(a,0,sizeof(a));
		scanf("%d %d",&n,&m);
        for(i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(j=0;j<n;j++)
			{
				if(a[j]>a[m])
					s++;
			}
		for(i=0;i<n;i++)
		{
			if(a[i]>a[m] && i>m)
			{
				for(j=i+1;j<n;j++)
					if(a[j]==a[m])
						s++;
				for(j=0;j<m;j++)
					if(a[j]==a[m])
						s++;
				break;
			}
			if(a[i]>a[m] && i<m)
			{
				for(j=i+1;j<m;j++)
					if(a[j]==a[m])
						s++;
				break;
			}
		}
		printf("%d\n",s);
	}
	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