325 - Identifying Legal Pascal Real Constants

All about problems in Volume 3. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: WA~ problem 325 Identifying Legal Pascal Real Constants

Post by Obaida »

I think i still need some more case to pass.. cause my code passed all the previous case but still wA.. :(
some one plz help me with test case for this program..

These are the steps that i followed to detect illegal input:

* Check whether the first character is e or E (without space, +, -)
* Check whether the last number is e(without spaces in the last).
* Check whether there is multiple e.
* Check whether there is dots '.' after e.
* Check whether there is any space inside the numbers.
* Check whether the dot '.' is the fast or last character.
* Check whether there is number on both side of the '.' dot.
* Check whether there is a '.' dot or 'e' or 'E' in the whole input.
* Check if there is a blank line then it is straight "is illegal."

>> And i reduced all the leading and trailing space.. If there is more then one space inside the input then i reduced it to single 1.

Is there any thing more to do? :-?
try_try_try_try_&&&_try@try.com
This may be the address of success.
Imti
Learning poster
Posts: 53
Joined: Sat Dec 04, 2010 12:00 pm
Location: Bangladesh
Contact:

Re: 325 DFA? WHY WA?

Post by Imti »

To:Jorge Pinto
problem stayement says:
Blanks may precede or follow the real constant, but they may not be embedded within it
So is there any input like 1 .2
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: WA~ problem 325 Identifying Legal Pascal Real Constants

Post by uDebug »

So, this problem's a bit tricky.

First, if you observe the sample input carefully, notice that the leading spaces are trimmed. So, for example, if this the input is

Code: Select all

                    +4.1234567890E-99999
*
then the AC output is

Code: Select all

+4.1234567890E-99999 is legal.
Next, it appears that the judge's input might not have trailing spaces - or if it does, then either trimming those trailing spaces or leaving them in the output gives AC. In my program, I trim the trailing spaces most of the time. So, for example, if the input's (with 4 trailing spaces)

Code: Select all

+7.2    
*
Then my AC program produces the following output

Code: Select all

7.2 is legal.
Note that the trailing whitespaces are trimmed in the output.

However, in the following case (when there's a space in between the constant)

Code: Select all

  E455555555   676           
*
My AC program produces the following output (without trimming the trailing spaces - but always trimming the leading spaces)

Code: Select all

E455555555   676            is illegal.
Also, it wasn't clear to me from reading the problem statement what the AC output for the following input should be

Code: Select all

44343e112         
*
The AC Output is

Code: Select all

44343e112 is legal.
Finally, junbin's test case helped me out. So here it is without the underscores - and the AC output.

Input:

Code: Select all

k  s jhsfdkkjsa df  sadf s
  dsfgh sdf gk dsf 

  2 2 3443 457 65
 2e3e2e2
 +e-2
 +2-1
 +2e-2
  +2e+2
 -2e-1-1 
 442
 3465374657846358634563865923569548236458263458623562835682346582364582364   
 34653746578463_5863456386592356_95482364582634586235_62835682346582364582364   
 45643856    
 4353 e 546456
 456456e345345    
462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576
 462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576+  
 462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576-  
 +462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576   
 462976592798713405193549823645926395628346589236458946e+4569223458726348563256238465872465876324576
 -462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576  
 462976592798713405193549823645926395628346589236458946e-4569223458726348563256238465872465876324576 
 +462976592798713405193549823645926395628346589236458946e-4569223458726348563256238465872465876324576 
 -462976592798713405193549823645926395628346589236458946e+4569223458726348563256238465872465876324576 
12e21
435e231e123e213
23e+355-14
+234+e234+E1234
3.2
459679346834596734956739476984396739476972394571936459823645863195629384658723653245235.37563286583645162847686587436587632475
457693476987495864364.5645634564564356e4563564564356543
457693476987495864364.5645634564564356e+4563564564356543
457693476987495864364.5645634564564356e-4563564564356543
+457693476987495864364.5645634564564356e4563564564356543
-457693476987495864364.5645634564564356e4563564564356543
457693476987495864364.+5645634564564356e4563564564356543
457693476987495864364.-5645634564564356e4563564564356543
*
AC Output:

Code: Select all

k  s jhsfdkkjsa df  sadf s is illegal.
dsfgh sdf gk dsf  is illegal.
 is illegal.
2 2 3443 457 65 is illegal.
2e3e2e2 is illegal.
+e-2 is illegal.
+2-1 is illegal.
+2e-2 is legal.
+2e+2 is legal.
-2e-1-1  is illegal.
442 is illegal.
3465374657846358634563865923569548236458263458623562835682346582364582364 is illegal.
34653746578463_5863456386592356_95482364582634586235_62835682346582364582364    is illegal.
45643856 is illegal.
4353 e 546456 is illegal.
456456e345345 is legal.
462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576 is legal.
462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576+ is illegal.
462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576- is illegal.
+462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576 is legal.
462976592798713405193549823645926395628346589236458946e+4569223458726348563256238465872465876324576 is legal.
_-462976592798713405193549823645926395628346589236458946e4569223458726348563256238465872465876324576   is illegal.
462976592798713405193549823645926395628346589236458946e-4569223458726348563256238465872465876324576 is legal.
+462976592798713405193549823645926395628346589236458946e-4569223458726348563256238465872465876324576 is legal.
-462976592798713405193549823645926395628346589236458946e+4569223458726348563256238465872465876324576 is legal.
12e21 is legal.
435e231e123e213 is illegal.
23e+355-14 is illegal.
+234+e234+E1234 is illegal.
3.2 is legal.
459679346834596734956739476984396739476972394571936459823645863195629384658723653245235.37563286583645162847686587436587632475 is legal.
457693476987495864364.5645634564564356e4563564564356543 is legal.
457693476987495864364.5645634564564356e+4563564564356543 is legal.
457693476987495864364.5645634564564356e-4563564564356543 is legal.
+457693476987495864364.5645634564564356e4563564564356543 is legal.
-457693476987495864364.5645634564564356e4563564564356543 is legal.
457693476987495864364.+5645634564564356e4563564564356543 is illegal.
457693476987495864364.-5645634564564356e4563564564356543 is illegal.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 325 - Identifying Legal Pascal Real Constants

Post by metaphysis »

For WA, try input:

Code: Select all

000040040.001200E-000000123
0e-0
*
output:

Code: Select all

000040040.001200E-000000123 is legal.
0e-0 is legal.
by the way, trim the leading and tailing space(Maybe the input of judge contain non tailing space). Use regex for this problem is easy.
Post Reply

Return to “Volume 3 (300-399)”