845 - Gas Station Numbers

All about problems in Volume 8. 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
yatsen
Learning poster
Posts: 68
Joined: Fri Nov 23, 2001 2:00 am
Location: taiwan

845 - Gas Station Numbers

Post by yatsen »

I keep WA for this problem. :cry:
Can anyone provide some test data ?
Or is any trap?

Daredevil
New poster
Posts: 19
Joined: Tue Apr 01, 2003 7:47 am
Location: Earth

845 - Gas Station Number WA?????

Post by Daredevil »

Can anyone help? This problem's driving me nuts!!! :evil: :evil:
Anyone can give some sample I/O???
Thanx in advance!!

Joseph Kurniawan
Experienced poster
Posts: 136
Joined: Tue Apr 01, 2003 6:59 am
Location: Jakarta, Indonesia

Post by Joseph Kurniawan »

I gave up on this prob long ago. But now since this prob is posted again, I become curious again. What's the trick on this prob?? Any sample I/O???
There are 3 things one need to be successful : motivation, ability and chance. And if you're a believer, make it four : God's will.

Per
A great helper
Posts: 429
Joined: Fri Nov 29, 2002 11:27 pm
Location: Sweden

Post by Per »

Some I/O:

Code: Select all

15444.1
0.9
0.1
0.2
0.3
0.6
324317.3
255555.5
2692592.9
0.0
0.1
1.1
5.5
6.6
9.9
6.9
.
Output:

Code: Select all

21144.4
6.0
1.0
0.5
3.0
0.9
324331.7
522222.2
2692595.6
The price cannot be raised.
1.0
The price cannot be raised.
The price cannot be raised.
6.9
The price cannot be raised.
9.6
I think they test for all the errors I made before getting AC. ;)
I liked this problem. It was kind of tricky since it looked very simple, but there were lots of things for me to do wrong :)

truckDriver
New poster
Posts: 5
Joined: Thu Oct 21, 2004 6:58 am

need your help ...

Post by truckDriver »

would Someone who get AC on this problem
give me a random test data & result that produced by AC Program..

i got several times WA...

that make me crazy ~~~~~~~~~ :cry:

plz help.............

technobug
Learning poster
Posts: 88
Joined: Sat Nov 15, 2003 6:41 pm
Location: Brasilien
Contact:

Post by technobug »

Per wrote:Some I/O:.......
I disagree..... the problem says:
She can simply rearrange the digits, possibly reversing some of them as described above.
Which means that she is able to rearrange the digits whenever she wants, and she can also reverse some of them as:....
The digit ``6" looks much like ``9" upside down. The digits ``0", ``1" and ``8" look like themselves. The digit ``2" looks a bit like a ``5" upside down (well, at least enough so that gas stations use it).
Which means, that for the same io:

65.2

The number 2 can be put upside down and becomes 5. The number 6 can be put upside down and becomes a 9.... which means that the biggest number should be:
95.5

There is no restriction on the problem on how many digits can we exchange positions or how many upside/down reversions we might use...

Anyone can help me out?

little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey »

You are required to print the next highest number, not the highest. In fact you can produce 24 different numbers from 65.2, ranging from 22.6, 22.9, ..., 65.2, 65.5, ..., 95.2, 95.5. In this list 65.5 immediately follows 65.2, so that's the number you should print.

technobug
Learning poster
Posts: 88
Joined: Sat Nov 15, 2003 6:41 pm
Location: Brasilien
Contact:

Post by technobug »

little joey wrote:You are required to print the next highest number, not the highest. In fact you can produce 24 different numbers from 65.2, ranging from 22.6, 22.9, ..., 65.2, 65.5, ..., 95.2, 95.5. In this list 65.5 immediately follows 65.2, so that's the number you should print.
thanks lj....

Unfortunately the following phrase is still ambigous:
Your job is to compute, given the current price of gas, the next highest price that can be displayed using exactly the same digits.
Next means either:

- the following price; the next price; the price after this one; not this one; but the next. So the problem requires the next price, only restricted that it should be higher than this one

or

- the closest price to the current one which is still higher than the current one (as you described).

Although english is not my mother language, I dont believe next stands for the last item mentioned above.

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

next highest price
Usually means exactly that.. it's common usage (at least in the states..)

technobug
Learning poster
Posts: 88
Joined: Sat Nov 15, 2003 6:41 pm
Location: Brasilien
Contact:

Post by technobug »

Larry wrote:
next highest price
Usually means exactly that.. it's common usage (at least in the states..)
solved... thanks for the reply...... so for me it was not a programming but language understanding challenge... :)

smile2ka10
New poster
Posts: 13
Joined: Wed Oct 26, 2005 10:14 pm
Location: Iran
Contact:

Post by smile2ka10 »

Try this I/O:
42184686335.0
265011917015725.1
114792935926963.2
24465570628146.3
23282168289962.4
492299611943.5
4828543732392.6
146053903154.7
2931238317422.8
187171971919896.9
54482172714772.0
11539187019913.1
256682630017036.2
98952870423812.3
313233033417674.4
4665151427712.5
28254686925548.6
276453266332758.7
20038128608724.8
974227530779.9
12317303622191.0
184328930107.1
9041894319265.2
226492744723806.3
15891673024371.4
153511500731102.5
24394354919630.6
126242408519955.7
18757118414967.8
73771393226309.9
169453244024627.0
11324553821539.1
16119208322930.2
16542483431116.3
46402965922705.4
9931139782307.5
31674223875022.6
287462692519073.7
6271583026778.8
15574509816513.9
23987132919162.0
186372235624768.1
23656155754032.2
12053273511151.3
169422172513967.4
34313110830192.5
180081133815458.6
122882775410384.7
14946891032210.8
97592422218589.9
64232494727507.0
130311641429169.1
9013259218763.2
1656174116360.3
276252053821549.4
6484275964042.5
36032435110292.6
30837937511021.7
45972402227349.8
232001966924485.9
8282473554.0
20002641927939.1
6901378918128.2
468372914894.3
246492248417808.4
2422143116618.5
22814951514310.6
76171893617452.7
20601525016520.8
315572279930304.9
6225110095845.0
326101499032703.1
3196204863094.2
14344305241588.3
2931595047449.4
25201134596619.5
205811979714799.6
152821959020799.7
280102715820473.8
236231853912293.9
60392418018191.0
2965879596192.1
198162288919157.2
11512162032635.3
242732005620329.4
22647263634887.5
188762843429870.6
20143238451417.7
218823199910323.8
18652100225700.9
35582847727893.0
24390507610713.1
2601251121004.2
268701786214689.3
13402979015256.4
16424500310586.5
241831028627089.6
314272861823758.7
9833309334170.8
21552572217190.9
.

Output:
42184686350.3
265011917015751.2
114792935926963.5
24465570628149.3
23282168289964.2
492299611945.3
4828543732392.9
146053903157.4
2931238317425.8
187171971919899.6
54482172714775.0
11539187019931.1
256682630017036.5
98952870423813.2
313233033417744.6
4665151427715.2
28254686925548.9
276453266332772.8
20038128608728.4
974227530796.7
12317303622601.1
184328930110.7
9041894319265.5
226492744723809.3
15891673024374.1
153511500731105.2
24394354919630.9
126242408519957.2
18757118414968.7
73771393226360.6
169453244024650.7
11324553821561.3
16119208322930.5
16542483431119.3
46402965922720.4
9931139782320.7
31674223875022.9
287462692519077.3
6271583026787.8
15574509816516.3
23987132919165.0
186372235624781.6
23656155754032.5
12053273511153.1
169422172513974.6
34313110830195.2
180081133815458.9
122882775410387.4
14946891032218.0
97592422218596.8
64232494727570.0
130311641429191.6
9013259218763.5
1656174116363.0
276252053821564.4
6484275964045.2
36032435110292.9
30837937511027.1
45972402227364.8
232001966924486.2
8282474022.3
20002641927961.3
6901378918128.5
468372914934.8
246492248417840.8
2422143116621.8
22814951514310.9
76171893617455.7
20601525016528.0
315572279930306.4
6225110095850.4
326101499032710.3
3196204863094.5
14344305241823.8
2931595047464.4
25201134596621.6
205811979714799.9
152821959020967.7
280102715820478.3
236231853912296.3
60392418018601.1
2965879596195.1
198162288919157.5
11512162032653.3
242732005620342.6
22647263635478.8
188762843429870.9
20143238451471.7
218823199910328.3
18652100225706.0
35582847727903.8
24390507610731.1
2601251121004.5
268701786214693.8
13402979015259.4
16424500310589.2
241831028627089.9
314272861823772.8
9833309334178.0
21552572217196.0

smile2ka10
New poster
Posts: 13
Joined: Wed Oct 26, 2005 10:14 pm
Location: Iran
Contact:

Post by smile2ka10 »

I 've put some sample random generated I/O here:
http://online-judge.uva.es/board/viewto ... 9762#49762

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re:

Post by DD »

Per wrote:Some I/O:

Code: Select all

15444.1
0.9
0.1
0.2
0.3
0.6
324317.3
255555.5
2692592.9
0.0
0.1
1.1
5.5
6.6
9.9
6.9
.
Output:

Code: Select all

21144.4
6.0
1.0
0.5
3.0
0.9
324331.7
522222.2
2692595.6
The price cannot be raised.
1.0
The price cannot be raised.
The price cannot be raised.
6.9
The price cannot be raised.
9.6
I think they test for all the errors I made before getting AC. ;)
I liked this problem. It was kind of tricky since it looked very simple, but there were lots of things for me to do wrong :)
Thanks for your input, and it helped me to get A.C.

Basically, I found the algorithm for this problem is very similar with finding the next permutation.
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.

Post Reply

Return to “Volume 8 (800-899)”