656 - Optimal Programs

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

Moderator: Board moderators

Post Reply
Jer
New poster
Posts: 10
Joined: Wed Nov 19, 2003 2:07 pm

656 - Optimal Programs

Post by Jer »

Can anyone explain the problem to me?

I don't know why the first test data is like that... :(

Code: Select all

4
1 2 3 4
0 -2 -6 -12

Program 1
DUP DUP MUL SUB
:wink: Thanks for your help

_____________________
Observer
Guru
Posts: 570
Joined: Sat May 10, 2003 4:20 am
Location: Hong Kong

Post by Observer »

OK. When the input is 1,

Code: Select all

1          <- Initially

1 1 1      <- After two DUPs

1 1        <- Multiply the top 2 entries

0          <- Subtraction of the 2 entries
Or when the input is 2,

Code: Select all

2          <- Initially

2 2 2      <- After two DUPs

2 4        <- Multiply the top 2 entries

-2         <- Subtraction of the 2 entries
I'm sure you know what's going on for input = 3 or 4 :wink:

Hope it helps~
7th Contest of Newbies
Date: December 31st, 2011 (Saturday)
Time: 12:00 - 16:00 (UTC)
URL: http://uva.onlinejudge.org
Post Reply

Return to “Volume 6 (600-699)”