Classic
Clean & simple
Crystal
Glassmorphism + Neon
Cyberpunk
Neon glitch art
🚫
违规Action检测
禁止Use右键菜单
⚠️ 此Action已被系统记录
1

Tautology

📝 Solutions 🔵 仅限 C++
Problems Description
<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>
Input格式
<p>Please Input Input Here</p>
Output格式
<p>Please Input Output Here</p>
Sample
Sample Input 1
ApNp ApNq 0
Sample Output 1
tautology not
Submit Code
请先Login后Submit

🤖 AI 解题助手

OpenRouter
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这problems题,可以帮你points析思路、提供Code示例。
🔓 完全Free · 无需消耗 Token