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 wzf123 at 2006-07-24 15:33:03 on Problem 2895
#include <stdio.h>
#include<string.h>
int main()
{
   int t,p,w,seat,i,k;
    long time1=0,time2=0,time;
   char a[2000];
   scanf("%d",&t);
   while(t--)
   {
     scanf("%d%d",&p,&w); 

       getchar();
        gets(a);

	  k=strlen(a)-1;
    
     for(i=0;i<=k;i++)

	 { 
		 if(a[i]!=' ')    
		{ 

		 if(a[i]<='O')
		 {
		  seat=(a[i]-65)%3+1;           //从A到O
		
	      time1+=seat*p;  //按键的时间  
		  
        if((a[i+1]-65)/3==(a[i]-65)/3)  //若在一起 等待的时间
	     time2+=w; 
        }
		

		 if(a[i]<='S'&&a[i]>='P')     //有四个键
		{  
		    
             seat=a[i]-'P'+1;
            time1+=seat*p; 
			if((a[i]-'P')/4==(a[i+1]-'P')/4)
	          time2+=w; 
         }

		 if(a[i]<='V'&&a[i]>='T')
		 {
		   seat=a[i]-'T'+1;
          time1+=seat*p; 
         if((a[i]-'T')/3==(a[i+1]-'T')/3)
               time2+=w; 

		 }

         if(a[i]<='Z'&&a[i]>='W')
		 {
             seat=a[i]-'w'+1;
            time1+=seat*p; 
          if((a[i]-'W')/4==(a[i+1]-'W')/4)
               time2+=w; 
		 }
		 }
      else time1+=p;
		}
       time=time1+time2;
       printf("%d\n",time); 
}
      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