一、如何判断永真式

给出WFF的定义,满足WFF前提下,且式子的值永为真,则是永真式(Tautology),给出WFF,判断是否为Tautology.

WFF定义:

永真?什么是“永真判断”

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.

因为p, q, r, s, t只能取0, 1,可以枚举他们的值来判断是否为永真式,这样又回到了用栈解决二目运算上了。一开始试图用两个栈分别装运算符和操作数,最后发现有些情况死活过不了,最后只好改回一个栈代码估计也只有我自己能看懂

#include

永真?什么是“永真判断”

#include

#include

#include

using namespace std;

string s;

int value[26];

char c[5]={'p','q','r','s','t'};

stack st;

int operate(int x, int y, char ch)

{

if(ch=='K') return x&& y;

if(ch=='A') return x| y;

if(ch=='C')

{

if(x== 1&& y== 0) return 0;

return 1;

}

if(ch=='E') return x== y;

}

bool dfs(int pos, int v)

{

if(pos>= 5)

{

while(!st.empty()) st.pop();

int i, l= s.size();

int x, y;

char ch;

for(i= 0; i< l; i++)

{

if(s[i]>='A'&& s[i]<='Z') st.push(s[i]);

else

{

x= value[s[i]-'a'];

if(st.size()> 0&& st.top()=='N')

{

while(st.size()> 0&& st.top()=='N')

{

x=(x+ 1)% 2;

st.pop();

}

}

if(st.size()> 0&&(st.top()'A'|| st.top()>'Z'))

{

while(st.size()> 0&&(st.top()'A'|| st.top()>'Z'))

{

y= st.top();

st.pop();

ch= st.top();

st.pop();

x= operate(x, y, ch);

while(st.size()> 0&& st.top()=='N')

{

x=(x+ 1)% 2;

st.pop();

}

}

}

st.push(x);

}

}

return st.top()== 1;

}

else

{

value[c[pos]-'a']= v;

if(pos== 4) return dfs(pos+ 1, 0);

else

return dfs(pos+ 1, 0)&& dfs(pos+ 1, 1);

}

}

int main()

{

while(cin>> s&& s!="0")

{

memset(value, 0, sizeof(value));

if(dfs(0, 0)&& dfs(0, 1)) printf("tautology\n");

else

printf("not\n");

}

}

二、只狼永真怎么打

《只狼:影逝二度》中,永真是游戏中正派医师,如果玩家选择了反派路线,也就是修罗结局,就会和永真交战,下面带来“powerPyx分享的永真具体打法。

点击查看:只狼BOSS攻略大全

永真打法

位置:天守阁上层

到达天守阁上层和枭对话,选择两次“舍弃皇子”,即可进入修罗结局,触发和永真的战斗。

打法思路:

建议先学“暗影冲刺”(技能忍者技能树最后那个技能,需要6个技能点),很适合用来打最后两个BOSS。方法很简单,离BOSS10米远(总之就是她打不到你的距离,具体自己目测)使用冲刺跳回逃跑重复。永真和之后的苇名一心都无法防御这招,所以想要稳定通关的话,重复前面的步骤就行了。

需要注意的地方就是把握好攻击距离,太远了可能打不到,太近的话又会被BOSS出招打断。

奖励:

触发苇名一心BOSS战。

三、什么是“永真判断”

给出WFF的定义,满足WFF前提下,且式子的值永为真,则是永真式(Tautology),给出WFF,判断是否为Tautology.

WFF定义:

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.

因为p, q, r, s, t只能取0, 1,可以枚举他们的值来判断是否为永真式,这样又回到了用栈解决二目运算上了。一开始试图用两个栈分别装运算符和操作数,最后发现有些情况死活过不了,最后只好改回一个栈代码估计也只有我自己能看懂

#include<iostream>

#include<string>

#include<vector>

#include<stack>

using namespace std;

string s;

int value[26];

char c[5]={'p','q','r','s','t'};

stack<char> st;

int operate(int x, int y, char ch)

{

if(ch=='K') return x&& y;

if(ch=='A') return x| y;

if(ch=='C')

{

if(x== 1&& y== 0) return 0;

return 1;

}

if(ch=='E') return x== y;

}

bool dfs(int pos, int v)

{

if(pos>= 5)

{

while(!st.empty()) st.pop();

int i, l= s.size();

int x, y;

char ch;

for(i= 0; i< l; i++)

{

if(s[i]>='A'&& s[i]<='Z') st.push(s[i]);

else

{

x= value[s[i]-'a'];

if(st.size()> 0&& st.top()=='N')

{

while(st.size()> 0&& st.top()=='N')

{

x=(x+ 1)% 2;

st.pop();

}

}

if(st.size()> 0&&(st.top()<'A'|| st.top()>'Z'))

{

while(st.size()> 0&&(st.top()<'A'|| st.top()>'Z'))

{

y= st.top();

st.pop();

ch= st.top();

st.pop();

x= operate(x, y, ch);

while(st.size()> 0&& st.top()=='N')

{

x=(x+ 1)% 2;

st.pop();

}

}

}

st.push(x);

}

}

return st.top()== 1;

}

else

{

value[c[pos]-'a']= v;

if(pos== 4) return dfs(pos+ 1, 0);

else

return dfs(pos+ 1, 0)&& dfs(pos+ 1, 1);

}

}

int main()

{

while(cin>> s&& s!="0")

{

memset(value, 0, sizeof(value));

if(dfs(0, 0)&& dfs(0, 1)) printf("tautology\n");

else

printf("not\n");

}

}