996 - Find the Sequence

All about problems in Volume 9. 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
Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

996 - Find the Sequence

Post by Wei-Ming Chen » Sun Jan 07, 2007 6:17 pm

I had some trouble in solving this problem

Can someone who have got AC tell me the answer of the test cases?

Thanks!

Code: Select all

1 2 2 2 2 2 2 2 2
1 1 2 3 4 5 6 7
2 2 3 4 5 6 7 8
8 500 600 700 1000 1200 1489 4563 12223 -7854 1456 3254

by the way, are there any space after input lines ?

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Sun Jan 07, 2007 7:17 pm

My AC code outputs

Code: Select all

[2]
[0]
[2+[1]]
[0]

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

Post by little joey » Sun Jan 07, 2007 9:34 pm

I get [1+[1]] for the second case, which is right IMO, and floating point exception (i.e. division by zero) on the fourth. I have the suspicion that the judge data is very weak, or even wrong, because I get WA if I fix the division by zero problem.

About the spaces: I don't know, but there might be. My program terminates when it either encounters EOF or a line without any digits.

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Mon Jan 08, 2007 8:30 am

The second cases M value is 1, so isn't [1+[1]] (which has two operator) invalid?

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

Post by little joey » Mon Jan 08, 2007 9:47 am

Oops, you're right. I counted only '+' and '*' as operators, but that's wrong. I wonder why my code got AC afterall...

Wei-Ming Chen
Experienced poster
Posts: 122
Joined: Sun Nov 13, 2005 10:25 am
Location: Taiwan

Post by Wei-Ming Chen » Mon Jan 08, 2007 3:58 pm

Thanks rio and little joey :D

Yes, there are some extra spaces after some inputs

here are some test cases

Code: Select all

6 2 6 8 9 14 25 44 89
10 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610
5 -1 -1 -1 -1 -1 -1 -1
7 2 2 2 2 2 2 2 -1 2 2 2 2 2
4 -200 100 400 700 1000 1300
4 10 90 1170 19890 417690 10442250 302825250 

Code: Select all

[0]
[0]
[-1]
[0]
[-200+[300]]
[2*[5+[4*[1]]]]

Post Reply

Return to “Volume 9 (900-999)”