ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1027. D++ Again

Help!!! I keep WA on test#9
Posted by odp 13 Feb 2005 06:49
#include "stdio.h"
#include "stdlib.h"
#define ex EOF
void recom()
{
 char a,b;
 a=getchar();
l:
 if(a==ex) {printf("NO\n");exit(0);}
 b=getchar();
 if(a=='*' && b==')') return;
 a=b;
 goto l;
}

main()
{
 char a,b;
 int k=0;
 a=getchar();
 while(a!=ex)
 {
  b=getchar();
  if(a=='(' && b=='*')
  {
   recom();
   a=getchar();
   continue;
  }
  if(a=='(')
  {
   k++;
   a=b;
   continue;
  }
  if(a==')')
  {
   if(k==0) {printf("NO\n");return 0;}
   k--;
   a=b;
   continue;
  }
  if(k!=0 && a!='\n' && a!='\r' && a!='=' && a!='+' && a!='-' && a!='*'
  && a!='/' && a<'0' && a>'9') {printf("NO\n");return 0;}
  a=b;
 }
 if(k!=0) printf("NO\n");
 else printf("YES\n");
}

Edited by author 13.02.2005 06:54
Re: Help!!! I keep WA on test#9
Posted by Sandro 14 Feb 2005 18:23
Be careful. Arithmetic expressions can't contain english letters. Try this test:

(1+a=2)
I got AC
Posted by odp 16 Feb 2005 11:04
Thank you!!

Edited by author 16.02.2005 12:41
Re: Help!!! I keep WA on test#9
Posted by WangSiyu 4 Sep 2005 08:00
Thanks, got AC now ^_^