Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:我来解释一下那些么明奇妙的WAIn Reply To:我来解释一下那些么明奇妙的WA Posted by:gyarenas at 2011-11-21 15:20:38 求解释我这段为啥也是C++WA G++AC #include <cstdio> #define M 105 char f[M], v[5]; int c; int eval() { char v1, v2; switch(f[c++]) { case 'K': v1 = eval(); v2 = eval(); return v1 && v2; case 'A': v1 = eval(); v2 = eval(); return v1 || v2; case 'N': v1 = eval(); return !v1; case 'C': v1 = eval(); v2 = eval(); return !v1 || v2; case 'E': v1 = eval(); v2 = eval(); return v1 == v2; default: return v[f[c-1] - 'p']; } } int dfs(int d) { if(d == 5) { c = 0; return eval(); } v[d] = 0; if(!dfs(d+1)) return 0; v[d] = 1; return dfs(d+1); } int main() { while(scanf("%s", f) && f[0]-'0') { if(dfs(0)) printf("tautology\n"); else printf("not\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator