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

3295 Tautolopy WA

Posted by 7109375 at 2018-03-02 22:26:49
//为什么这个程序WA

#include<cstdio>
#include<cctype>

int var[6];//p,q,r,s,t
char *head,WFF[105];

bool expr()
{
	char c=*head;head++;
	if (islower(c))return var[c-'p'];
	if (c=='K')
	{
		bool b=expr();
		return b && expr();
	}else if (c=='A')
	{
		bool b=expr();
		return b || expr();
	}else if (c=='N')
	{
		return !expr();
	}else if (c=='C')
	{
		bool b=expr();
		return !b || expr();
	}else if (c=='E')
	{
		bool b=expr();
		return !(b ^ expr());
	}
}

int main()
{
	while(scanf("%s",WFF)==1 && WFF[0] != '0')
	{
		bool zero=false,one=false;
		for (var[0]=0;var[0]<2;var[0]++)
			for (var[1]=0;var[1]<2;var[1]++)
				for (var[2]=0;var[2]<2;var[2]++)
					for (var[3]=0;var[3]<2;var[3]++)
						for (var[4]=0;var[4]<2;var[4]++)
						{
							head=WFF;
							if(expr())one=true;
							else zero=true;
						}
		printf(one && !zero ? "tautology\n":"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