zoukankan      html  css  js  c++  java
  • Poj 3295

    题目大意:略

    解:暴力枚举rqst之流的状态就行了,状态数不多,对运算顺序困惑了下,看了看题解是用栈自后往前弄。

    View Code
     1 //Tautology
     2 const
     3         ttttt='tautology';
     4         fffff='not';
     5         inf='1.txt';
     6         maxl=111;
     7 var
     8         ask: string;
     9         ans: boolean;
    10         stack: array[0..maxl]of longint;
    11         tot : longint;
    12 
    13 procedure main;
    14 var
    15         l, tmp, p, q, r, s, t: longint;
    16         c: char;
    17 begin
    18   ans := true;
    19   for p := 0 to 1 do
    20     for q := 0 to 1 do
    21       for r := 0 to 1 do
    22         for s := 0 to 1 do
    23           for t := 0 to 1 do begin
    24             l := length(ask);
    25             tot := 0;
    26             while l>0 do begin
    27               c := ask[l];
    28               case c of
    29                 'q', 'p', 'r', 's', 't': begin
    30                   inc(tot);
    31                   case c of
    32                     'q':stack[tot] := q;
    33                     'p':stack[tot] := p;
    34                     'r':stack[tot] := r;
    35                     's':stack[tot] := s;
    36                     't':stack[tot] := t;
    37                   end;
    38                 end;
    39                 'N':stack[tot] := stack[tot] xor 1 ;
    40                 'K':begin
    41                   dec(tot);
    42                   stack[tot] := stack[tot] and stack[tot+1];
    43                 end;
    44                 'A':begin
    45                   dec(tot);
    46                   stack[tot] := stack[tot] or stack[tot+1];
    47                 end;
    48                 'C':begin
    49                   dec(tot);
    50                   stack[tot] := ((stack[tot]xor stack[tot+1])xor 1)or(stack[tot])
    51                 end;
    52                 'E':begin
    53                   dec(tot);
    54                   stack[tot] := (stack[tot]xor stack[tot+1])xor 1;
    55                 end;
    56               end;
    57               dec(l);
    58             end;
    59             if stack[1]=0 then begin
    60               ans := false; exit;
    61             end;
    62           end;
    63 end;
    64 
    65 procedure print;
    66 begin
    67   if ans then writeln(ttttt)
    68     else writeln(fffff);
    69 end;
    70 
    71 begin
    72   assign(input,inf); reset(input);
    73   read(ask); readln;
    74   while ask<>'0' do begin
    75     main;
    76     print;
    77     read(ask); readln;
    78   end;
    79 end.
  • 相关阅读:
    数据库字段说明查询
    MUI 微信支付代码
    数据库 批量删除表
    c# 微信开发 《内容回复或事件触发》
    C# 微信开发 《验证签名》
    SQL SERVER占用CPU过高排查和优化
    类属性验证简单说明
    地图纠偏
    区块链-6一个故事告诉你比特币的原理及运作机制
    区块链-5区块链技术入门,涉及哪些编程语言?
  • 原文地址:https://www.cnblogs.com/wmzisfoolish/p/2490581.html
Copyright © 2011-2022 走看看