21156_Tautology

2022-5-16 18:18| 发布者: Hocassian| 查看: 35| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504944622100-Problem List-采集的数据-后羿采集器.html

Pro.ID

21156

Title

Tautology

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21156

AC

7

Submit

13

Ratio

53.85%

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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, q, r, s, and t are WFFs

    • if w is a WFF, Nw is a WFF

    • if w and x are WFFs, Kwx, Awx, Cwx, and Ewx are WFFs.

    The meaning of a WFF is defined as follows:

    • p, q, r, s, and t are logical variables that may take on the value 0 (false) or 1 (true).

    • K, A, N, C, E mean and, or, not, implies, and equals as defined in the truth table below.

    Definitions of K, A, N, C, and E
     wx  Kwx  Awx   Nw  Cwx  Ewx
     1  1  1  1   0  1  1
     1  0  0  1   0  0  0
     0  1  0  1   1  1  0
     0  0  0  0   1  1  1

    A tautology is a WFF that has value 1 (true) regardless of the values of its variables. For example, ApNp is a tautology because it is true regardless of the value of p. On the other hand, ApNq is not, because it has the value 0 for p=0, q=1.

    You must determine whether or not a WFF is a tautology.

    输入

    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.

    输出

    Description

    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, q, r, s, and t are WFFs

    • if w is a WFF, Nw is a WFF

    • if w and x are WFFs, Kwx, Awx, Cwx, and Ewx are WFFs.

    The meaning of a WFF is defined as follows:

    • p, q, r, s, and t are logical variables that may take on the value 0 (false) or 1 (true).

    • K, A, N, C, E mean and, or, not, implies, and equals as defined in the truth table below.

    Definitions of K, A, N, C, and E
     wx  Kwx  Awx   Nw  Cwx  Ewx
     1  1  1  1   0  1  1
     1  0  0  1   0  0  0
     0  1  0  1   1  1  0
     0  0  0  0   1  1  1

    A tautology is a WFF that has value 1 (true) regardless of the values of its variables. For example, ApNp is a tautology because it is true regardless of the value of p. On the other hand, ApNq is not, because it has the value 0 for p=0, q=1.

    You must determine whether or not a WFF is a tautology.

    Input

    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.

    Output

    For each test case, output a line containing tautology or not as appropriate.

    Sample Input

    ApNp
    ApNq
    0

    Sample Output

    tautology
    not

    Source

    样例输入

    ApNp
    ApNq
    0

    样例输出

    tautology
    not

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部