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

Re:请问为什么函数有参数会超时呢?????

Posted by Wangshufeng3 at 2012-09-12 16:01:28 on Problem 3295
In Reply To:贴个代码,给大家抛砖引玉。。。 Posted by:schnee at 2010-07-22 09:37:12
#include<iostream>
#include<cstring>
using namespace std;
int state,isOk;
char s[210];
int l = 0;
int f( int pos)
{
   char ch = s[pos];
   printf("");
   switch( ch )
   {
      case 'p':
	  case 'q':
	  case 'r':
	  case 's':
	  case 't':
	  	   return (state>>(ch-'p'))&1;
	  	   break;
      case 'K':
	  	   return f(pos+1)&f(pos+2);
	  	   break;
      case 'A':
	  	   return f(pos+1)|f(pos+2);
	  	   break;
      case 'N':
	  	   return !f(pos+1);
	  	   break;
      case 'C':
	  	   return !f(pos+1)|f(pos+2);
	  	   break;
      case 'E':
	  	   return f(pos+1)==f(pos+2);
	  	   break;
      default:
  		   break;
	  		   
   } 	
}
int main()
{
   while(scanf("%s",s),s[0]!='0')
   {
       
	   isOk = 1;
       for(state =0;state<32;state++)
       {
		   l = 0;
	       if(f(0)==0)
		      isOk = 0;			 
       }
	   if(isOk)  
	       printf("tautology\n");
       else
           printf("not\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