Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <stack>
- using namespace std;
- int main() {
- char s[1005];
- int i, j;
- while(scanf("%s", s) && s[0] != '0') {
- int ret = 1, len = strlen(s);
- int a, b;
- for(i = 0; i < 32; i++) {
- stack<int> stk;
- for(j = len-1; j >= 0; j--) {
- if(s[j] >= 'p') {
- int val = (i>>(s[j]-'p'))&1;
- stk.push(val);
- } else {
- a = stk.top(), stk.pop();
- if(s[j] != 'N') {
- b = stk.top(), stk.pop();
- }
- if(s[j] == 'K')
- stk.push(a&b);
- if(s[j] == 'A')
- stk.push(a|b);
- if(s[j] == 'N')
- stk.push(!a);
- if(s[j] == 'C')
- stk.push(!(a&(!b)));
- if(s[j] == 'E')
- stk.push(a == b);
- }
- }
- ret &= stk.top();
- }
- puts(ret ? "tautology" : "not");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement