Page **1** of **1**

### 189 Can anyone explain it to me?

Posted: **Sat Oct 11, 2003 8:36 am**

by **..**

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
READLN ( TEMP.SECOND);
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!

Posted: **Sat Oct 11, 2003 11:50 am**

by **Farid Ahmadov**

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
READLN ( TEMP.SECOND);
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.

Posted: **Fri Nov 07, 2003 1:34 pm**

by **halyavin**

Don't forget about this test:

begin

writeln('~~~~~~');

{~~~~~~~~~~~~~}

end.

~~anonimus

Posted: **Wed Dec 17, 2003 9:00 am**

by **junbin**

halyavin wrote:Don't forget about this test:

begin

writeln('~~~~~~');

{~~~~~~~~~~~~~}

end.

~~anonimus

Answer for this is 5 units right?

### 189 - Pascal Program Lengths

Posted: **Wed Jun 01, 2005 9:58 pm**

by **mt**

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?

Posted: **Sat Mar 04, 2006 3:07 am**

by **Margarita**

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

### 189 WA

Posted: **Thu May 18, 2006 8:03 pm**

by **snar**

Hi,

I

Posted: **Fri Sep 21, 2007 5:25 pm**

by **Jan**

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:**
Hope it helps.

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

Posted: **Fri Apr 10, 2009 8:10 pm**

by **deadangelx**

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.

### Re: 189 - Pascal Program Lengths

Posted: **Wed Oct 22, 2014 9:14 pm**

by **brianfry713**

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 (*

### Re: 189 - Pascal Program Lengths

Posted: **Wed Mar 25, 2015 3:53 pm**

by **anacharsis**

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.

### Re: 189 - Pascal Program Lengths

Posted: **Mon Feb 06, 2017 12:14 am**

by **Dominik Michniewski**

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 ...

### Re: 189 - Pascal Program Lengths

Posted: **Mon Feb 06, 2017 10:22 pm**

by **Dominik Michniewski**

Never mind, I found my silly mistake in parsing identifiers