Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:请问为什么函数有参数会超时呢?????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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator