## 189 - Pascal Program Lengths

Moderator: Board moderators

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

### 189 Can anyone explain it to me?

Hi all,
I don't understand how to the get the sample output (29 units),
this is how I count the program, what's wrong?

Code: Select all

``````PROGRAM SAMPLEINPUT;
1       2

VAR
3
TEMP : RECORD
4      5
FIRST, SECOND : REAL;
6      7        8
END;
9

BEGIN {Ignore this }
10   11
TEMP.FIRST := 5.0E -  2;
12         13 14  15 16
17     18 19
WRITELN ( 'THE ANSWER IS', TEMP.FIRST *  TEMP.SECOND : 7 : 3)
20     21 22               23         24 25            26 27
END.
28

~~A. N. Onymous``````
Thanks!
My signature:
We can learn much more in discussion than reading source code.
• I HATE testing account.
• Don't send me source code for debug.

Experienced poster
Posts: 131
Joined: Thu Apr 17, 2003 8:39 am
Location: Baku, Azerbaijan
Hi ..
I haven't solved this problem yet. But I think you are counting wrong.

Code: Select all

``````1       2
PROGRAM SAMPLEINPUT;

3
VAR

4      5
TEMP : RECORD

6      7        8
FIRST, SECOND : REAL;

9
END;

10
BEGIN {Ignore this }

11   12    13 14
TEMP.FIRST := 5.0E-2;

15     16 17   18

19      20 21               22   23     24 25   26       27  28
WRITELN (  'THE ANSWER IS', TEMP.FIRST  *  TEMP.SECOND : 7 : 3  )

29
END.
~~A. N. Onymous
``````
I think it must be correct. 5.0E-2 is a constant. If there is "E" after a real number then there will sign(+ or -) and some integer number right after it. There cannot be something like: 5.0 E - 2 it will always be 5.0E-2. Hope it will help.
_____________
NO sigNature

halyavin
New poster
Posts: 3
Joined: Thu Nov 06, 2003 4:36 pm
begin
writeln('~~~~~~');
{~~~~~~~~~~~~~}
end.
~~anonimus

junbin
Experienced poster
Posts: 174
Joined: Mon Dec 08, 2003 10:41 am
begin
writeln('~~~~~~');
{~~~~~~~~~~~~~}
end.
~~anonimus
Answer for this is 5 units right?

mt
New poster
Posts: 1
Joined: Wed Jun 01, 2005 9:48 pm

### 189 - Pascal Program Lengths

Hi, all.

I've got a lot of WA on this problem.
I suspect there is something tricky about it.

Does anyone give me a clue?

Margarita
New poster
Posts: 8
Joined: Mon Jan 23, 2006 7:28 pm
Location: Ukraine, Kharkiv
Contact:
Hi 2 all!
can anyone give me some big test, syntactically correct, to check my program? i have runtime error at 0.000 time... what a pity
thanks

snar
New poster
Posts: 44
Joined: Thu Sep 01, 2005 12:14 pm
Location: Yerevan, Armenia

### 189 WA

Hi,

I
Narek Saribekyan

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Contact:
Try the set..

Input:

Code: Select all

``````program test;
VAR
ch : array [1..20] of Char;
BEGIN {Ignore 'like a string'}
(* Comments can be splitted over several lines
and all the operators like + - * / should be ignored
*) Temp := 2;
iden := \$abFe90;
_iden_ := 1e-90;
END.
~~Jan``````
Output:

Code: Select all

``Program by Jan contains 21 units.``
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

New poster
Posts: 32
Joined: Tue Feb 13, 2007 1:31 pm

### Re: 189 Can anyone explain it to me?

I give a super critical input and output, some codes are from Jan, thanks.

input

Code: Select all

``````program test;
VAR
ch:array['a' .. 'z']of Char;
BEGIN{Ignore 'like a
string'}
(* Comments can be splitted over several lines
and all the operators like + - * / should be ignored
*)Temp:=2;
WRITELN ('''', TEMP.FIRST <= TEMP.SECOND : 7 : 3)
WRITELN ('''a is b''s', TEMP.FIRST <> TEMP.SECOND : 7 : 3)
iden:=(\$abFe90+1e-90)*2;
END.
~~bleed1979
``````
output

Code: Select all

``````Program by bleed1979 contains 43 units.
``````
Hope it helps.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 189 - Pascal Program Lengths

From the problem statement:
The only comment delimiters that you should recognise are {}, and not (**).

So you don't need to handle the I/O posted by Jan and deadangelx to get AC. The judge's input does not contain (*
Check input and AC output for thousands of problems on uDebug!

anacharsis
Learning poster
Posts: 69
Joined: Mon Feb 09, 2015 1:56 am

### Re: 189 - Pascal Program Lengths

So, this is actually Algol, but it's close enough to Pascal that you can use your Pascal unit counter/lexer on it.
It helped me get AC

Input:

Code: Select all

``````begin
comment Algol program print the primes less than 1000 using the
sieve method.;
Boolean array sieve[2:1000];
integer p, count;

comment Eliminate the multiples of the argument prime number;
procedure eliminate(p);
integer p;
begin
integer i;
for i := 2*p step p until 1000 do
sieve[i] := false
end;

comment Clear the sieve.;
integer i;
for i := 2 step 1 until 1000 do
sieve[i] := true;

comment Find the primes in range.;
for i := 2 step 1 until 1000 do
if sieve[i] then
eliminate(i);

comment Print the results, 10 per line.;
p := 2;
for count := 0 while p <= 1000 do begin
comment This construct is similar to a do .. while built with a goto.;
makeline:
if sieve[p] then begin
outinteger(1,p);
outstring(1,' ');
count := count + 1
end;
p := p + 1;
if p <= 1000 & count < 10 then goto makeline;
outstring(1,'\n')
end

end
~~Algol
``````
Output
Program by Algol contains 176 units.

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

### Re: 189 - Pascal Program Lengths

Could anyone help me with any tricky input ?
I have got Wrong Answer with 0.000 time and I have passed all cases posted in this thread ...
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

### Re: 189 - Pascal Program Lengths

Never mind, I found my silly mistake in parsing identifiers
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)