NALP's blog

By NALP, 9 years ago, translation, In English,

A. Extra-terrestrial Intelligence

This task is very easy, and I hope all of you have solved it. But let's talk about it.

Let input sequence is named as a, and its length is n. Then let's save sequence x1, ..., xk is increasing order - all of positions, where axi = '1'.

We must check if this sequence x1, ..., xk is a arithmetic progression. We save variable d = x2 - x1 and check:
for all 1 ≤ i < k, is "d = xi + 1 - xi" correct.

If it's correct, output "YES", else "NO".
  • Vote: I like it
  • +12
  • Vote: I do not like it