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 xuguangshengqq at 2009-03-08 21:21:44 on Problem 2937
#include <stdio.h>
#include <string.h>
#include <memory.h>
//2937


int main()
{
  int n,len;
  int m,r,i;
  int flag;
  int temp;
  char line[1000200];
  while(1)
  {
    scanf("%d",&n);
	gets(line);
	if(n==0)
	  break;
	else
	{
	  memset(line,0,sizeof(line));
	  //scanf("%s",&line);
	  gets(line);
	  //printf("%s\n",line);
      len = strlen(line);
	  temp = 0;
	  m = 0;
	  r = 0;
	  for(i=0;i<len;i++)
	  {  //printf("line[%d] = %c\n",i,line[i]);
	     if(line[i]=='r')
		 {
		   flag = 0;
		 }
		 else if(line[i]=='m')
		 {
		   flag = 1;
		 }
		 else if(line[i]==' ')
		 {  
			 //printf("temp == %d\n",temp);
		    if(flag==0)
			{
			  if(m == 0)//仍然是原方向
			  {
			    r+=temp;
				r%=n;
			  }
			  else // m==1
			  {
			    temp%=n;
				r+=n;
				r-=temp;
                r%=n;
				temp = 0;
			  }
			}
			else// flag == 1
			{
			  m = (m+temp)%2;
			  temp = 0;
			}
		//	printf("m = %d  r = %d\n",m,r);
		 }
		 else //0-------9
		 {
		   temp*=10;
		   temp+=(line[i]-'0');
		 }
	  }//for
	}//else
     
       //printf("temp == %d\n",temp);

            if(flag==0)
			{
			  if(m == 0)//仍然是原方向
			  {
			    r+=temp;
				r%=n;
			  }
			  else // m==1
			  {
			    temp%=n;
				r+=n;
				r-=temp;
                r%=n;
			  }
			}
			else// flag == 1
			{
			  m = (m+temp)%2;
			}
		 
		 


//printf("m = %d  r = %d\n",m,r);



	if(m==0)
	{
	   if(r!=0)
		  {
	        printf("r%d\n",r);
		  }
		  else
		  {
		    printf("\n");
		  }
	}
	else if(m==1)
	{
	  if(r*2>n)
	  {
	    printf("m1 r%d\n",(n-r));
	  }
	  else
	  {
		  if(r!=0)
		  {
	        printf("r%d m1\n",r);
		  }
		  else
		  {
		    printf("m1\n");
		  }
	  }
	}
  }//while
  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