经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Tautology

📝 题解 🔵 仅限 C++
题目描述
<p>WFF 'N PROOF is a logic game played with dice. Each die has six faces representing some subset of the possible symbols K, A, N, C, E, p, q, r, s, t. A Well-formed formula (WFF) is any string of these symbols obeying the following rules:</p> <ul> <li>p, q, r, s, and t are WFFs</li> <li>if <i>w</i> is a WFF, N<i>w</i> is a WFF</li> <li>if <i>w</i> and <i>x</i> are WFFs, K<i>wx</i>, A<i>wx</i>, C<i>wx</i>, and E<i>wx</i> are WFFs.</li> </ul> <p>The meaning of a WFF is defined as follows:</p> <ul> <li>p, q, r, s, and t are logical variables that may take on the value 0 (false) or 1 (true).</li> <li>K, A, N, C, E mean <i>and, or, not, implies,</i> and <i>equals</i> as defined in the truth table below.</li> </ul> <center> <table border="1" bgcolor="#ccffff" width="80%" cols="1"> <tbody> <tr> <td><center><b><font color="#000099"><font size="+1">Definitions of K, A, N, C, and E</font></font></b></center></td> </tr> </tbody> </table> <table border="1" bgcolor="#ccffff" width="80%" cols="6"> <tbody> <tr> <td>&nbsp;&nbsp;&nbsp;&nbsp; <b><font face="Courier New,Courier"><font size="+1"><i>w</i>&nbsp; <i>x</i></font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; K<i>wx</i></font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; A<i>wx</i></font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp;&nbsp; N<i>w</i></font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; C<i>wx</i></font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; E<i>wx</i></font></font></b></td> </tr> <tr> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp;&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> </tr> <tr> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp;&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> </tr> <tr> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp;&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> </tr> <tr> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 0</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp;&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> <td><b><font face="Courier New,Courier"><font size="+1">&nbsp; 1</font></font></b></td> </tr> </tbody> </table> </center> <p>A <i>tautology</i> is a WFF that has value 1 (true) regardless of the values of its variables. For example, <i>ApNp</i> is a tautology because it is true regardless of the value of <i>p</i>. On the other hand, <i>ApNq</i> is not, because it has the value 0 for <i>p=0, q=1</i>.</p> <p>You must determine whether or not a WFF is a tautology.</p> <p>Input consists of several test cases. Each test case is a single line containing a WFF with no more than 100 symbols. A line containing 0 follows the last case. For each test case, output a line containing <i>tautology</i> or <i>not</i> as appropriate.</p>
输入格式
<p>Please Input Input Here</p>
输出格式
<p>Please Input Output Here</p>
样例
样例输入 1
ApNp ApNq 0
样例输出 1
tautology not
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用