10930  ASequence
Moderator: Board moderators
10930  ASequence
I can not clearly understand problem.
I can not understand [quote]"earlier terms of the sequence"[/quote]
Plase clarify me with example.
I can not understand [quote]"earlier terms of the sequence"[/quote]
Plase clarify me with example.
Mr. Arithmetic logic Unit
What is the correct output for the following input.
Code: Select all
5 1 2 4 8 12
5 1 5 7 9 12
5 10 11 12 13 21
5 1 2 4 12 8
Mr. Arithmetic logic Unit
Output:
Code: Select all
Case #1: 1 2 4 8 12
This is not an Asequence.
Case #2: 1 5 7 9 12
This is not an Asequence.
Case #3: 10 11 12 13 21
This is not an Asequence.
Case #4: 1 2 4 12 8
This is not an Asequence.
Ami ekhono shopno dekhi...
HomePage
HomePage
But Yet I am getting wrong answer.
Where is the problem?.
Sorry for my posting code.
Where is the problem?.
Sorry for my posting code.
Code: Select all
Remove After getting Accepted.
Last edited by TISARKER on Sun Oct 09, 2005 12:20 pm, edited 2 times in total.
Mr. Arithmetic logic Unit
Just follow the algorithm >
'Edited'  The input set is updated.
Code: Select all
1. Take the input and print them.
2. Check a number is greater than the previous one.
3. Check duplicates.
4. Check the sum.
Last edited by Jan on Mon Nov 14, 2005 10:17 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage
HomePage
I follow ur algorithm.But yetJan wrote:Just follow the algorithm >
Code: Select all
1. Take the input and print them. 2. Sort the values. 3. Check duplicates. 4. Check the sum.
I got Wrong answer.why?
My another question
Please help me.Remove my question after getting a sense
Last edited by TISARKER on Sun Oct 09, 2005 11:27 am, edited 1 time in total.
Mr. Arithmetic logic Unit
Code: Select all
5 1 2 4 12 8
Now after sorting you get
1 2 4 8 12
....
Here you can make 12 by summing 8 and 4
....
So,
Output will be
This is not an Asequence.
Ami ekhono shopno dekhi...
HomePage
HomePage
If the values are not sorted already, the input is not an Asequence.Jan wrote:Just follow the algorithm >
Code: Select all
1. Take the input and print them. 2. Sort the values. 3. Check duplicates. 4. Check the sum.
Your algorithm will say that "2 1" is an Asequence, which it is not.
My algorithm for each sequence is bellow.
If my algorithm is correct where is the problem?.
Please tell me.
I am hopeless for my performance.
According to my algorithm my code is given above post.1. Take the input and print them.
2.
a)If evry ak>a1..ak1 then continue next.
b)Otherwise print the input is not an Asequence.
3.
a)Check the sum for all possible 2 or more sequential terms a1..ak1.
b).If (sum==ak)print the input is not an Asequence.
5.printf input is an Asequence.
If my algorithm is correct where is the problem?.
Please tell me.
I am hopeless for my performance.
Mr. Arithmetic logic Unit
Per, I have got many WA's in this problem. I checked if the current value is greater than the previous one, otherwise print 'not Asequence'.
After many WA's I have changed my code. After printing, I sort the values. And then the rest was same. The only difference was sorting. And I got Accepted. So, My code returns 'Asequence' when the input is 2 1.
After many WA's I have changed my code. After printing, I sort the values. And then the rest was same. The only difference was sorting. And I got Accepted. So, My code returns 'Asequence' when the input is 2 1.
Ami ekhono shopno dekhi...
HomePage
HomePage

 Guru
 Posts: 1080
 Joined: Thu Dec 19, 2002 7:37 pm
TISARKER, your step 3a is wrong, the terms to be summed don't have to be sequential:
is not an Asequence because 21=1+4+16.
Jan, that's very strange. Are you shure you didn't change anything else when you added the sorting step? Per's approach is the only correct one and anything else should get WA, or else the input is too weak.
Code: Select all
6 1 2 4 8 16 21
Jan, that's very strange. Are you shure you didn't change anything else when you added the sorting step? Per's approach is the only correct one and anything else should get WA, or else the input is too weak.
Just try the input.
Input:
But your code returns 'Asequence'.
Input:
Code: Select all
5 1 3 5 7 13
Code: Select all
Case #1: 1 3 5 7 13
This is not an Asequence.
Ami ekhono shopno dekhi...
HomePage
HomePage
I m sure that I haven't change anything when sorting. If u want I can give you both codes. And may be the input is too weak.little joey wrote: Jan, that's very strange. Are you sure you didn't change anything else when you added the sorting step? Per's approach is the only correct one and anything else should get WA, or else the input is too weak.
Ami ekhono shopno dekhi...
HomePage
HomePage

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