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

### 10930 - A-Sequence

Posted: **Sun Oct 09, 2005 1:38 am**

by **TISARKER**

I can not clearly understand problem.

I can not understand [quote]"earlier terms of the sequence"[/quote]

Plase clarify me with example.

Posted: **Sun Oct 09, 2005 2:24 am**

by **Emilio**

earlier terms of the sequence

Let be a sequence a1, a2, ..., an

The earlier terms of an element ak, 1<=k<=n, there are the terms, a1, a2, ..., a(k-1)

Example:

1 2 3 9

The earlier terms of 1 is nothing.

The earlier terms of 2 is 1.

The earlier terms of 3 are 1,2.

The earlier terms of 9 are 1,2,3.

Posted: **Sun Oct 09, 2005 3:21 am**

by **TISARKER**

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

Posted: **Sun Oct 09, 2005 3:45 am**

by **Jan**

**Output:**
Code: Select all

```
Case #1: 1 2 4 8 12
This is not an A-sequence.
Case #2: 1 5 7 9 12
This is not an A-sequence.
Case #3: 10 11 12 13 21
This is not an A-sequence.
Case #4: 1 2 4 12 8
This is not an A-sequence.
```

Posted: **Sun Oct 09, 2005 5:13 am**

by **TISARKER**

But Yet I am getting wrong answer.

Where is the problem?.

Sorry for my posting code.

Posted: **Sun Oct 09, 2005 5:38 am**

by **Jan**

Just follow the algorithm ->

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

'Edited' - The input set is updated.

Posted: **Sun Oct 09, 2005 6:47 am**

by **TISARKER**

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

I follow ur algorithm.But yet

I got Wrong answer.why?

My another question

Remove my question after getting a sense

**Please help me.**

Posted: **Sun Oct 09, 2005 6:55 am**

by **Jan**

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 A-sequence.
```

Posted: **Sun Oct 09, 2005 9:11 am**

by **Per**

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

If the values are not sorted already, the input is not an A-sequence.

Your algorithm will say that "2 1" is an A-sequence, which it is not.

Posted: **Sun Oct 09, 2005 11:10 am**

by **TISARKER**

**My algorithm for each sequence is bellow.**
1. Take the input and print them.

2.

a)If evry ak>a1..ak-1 then continue next.

b)Otherwise print the input is not an A-sequence.

3.

a)Check the sum for all possible 2 or more sequential terms a1..ak-1.

b).If (sum==ak)print the input is not an A-sequence.

5.printf input is an A-sequence.

**According to my algorithm my code is given above post.**

If my algorithm is correct where is the problem?.

Please tell me.

I am hopeless for my performance.

Posted: **Sun Oct 09, 2005 11:10 am**

by **Jan**

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 A-sequence'.

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 'A-sequence' when the input is 2 1.

Posted: **Sun Oct 09, 2005 11:31 am**

by **little joey**

TISARKER, your step 3a is wrong, the terms to be summed don't have to be sequential:

is not an A-sequence 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.

Posted: **Sun Oct 09, 2005 11:33 am**

by **Jan**

Just try the input.

**Input:**
Code: Select all

```
Case #1: 1 3 5 7 13
This is not an A-sequence.
```

But your code returns 'A-sequence'.

Posted: **Sun Oct 09, 2005 11:49 am**

by **Jan**

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.

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.

Posted: **Sun Oct 09, 2005 12:06 pm**

by **little joey**

I believe you, of course.

But a program that says that Per's example "2 1" is an A-sequence should get WA. If it gets AC, the input is too weak.