Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

sj02012006's blog

By sj02012006, history, 9 months ago, In English

You are given an infinite sequence of positive integers: 1, 2, 3, 4, 5, 6, 7, 8, ...

An infinite number of operations are performed on this sequence: In the 1st operation, every 2nd element is removed. In the 2nd operation, every 3rd element of the remaining sequence is removed. In the 3rd operation, every 4th element is removed. In the i-th operation, every (i + 1)-th element is removed. These operations continue indefinitely.

You are given an integer x. Determine whether x will remain in the sequence forever or be removed at some operation.

Input : 13

1,2,3,4,5,6,7,8,9,10,11,12,13

1st operation (remove every 2nd):

1,3,5,7,9,11,13

2nd operation (remove every 3rd):

1,3,7,9,13

3rd operation (remove every 4th):

1,3,7,13

4th operation (remove every 5th): No 5th element exists

Answer: YES

Input : 17

Answer: NO

Full text and comments »

  • Vote: I like it
  • -22
  • Vote: I do not like it