PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000010. Dãy căn, logarit và sin (Sqrt Log Sin)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Dãy căn, logarit và sin (Sqrt Log Sin)

Sqrt Log Sin

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Consider the integer sequence (xi)(x_i) defined by

x0=1,x_0=1, $$x_i=\big(x_{i-\lfloor\sqrt{i}\rfloor}+x_{\lfloor\ln i\rfloor}+x_{\lfloor i\sin^2(i)\rfloor}\big)\bmod 1\,000\,000\qquad(i\ge1).$$

Here ⌊x⌋\lfloor x\rfloor denotes the floor function, ln⁡\ln is the natural logarithm, and sin⁡\sin takes its argument in radians.

Compute the sequence value xix_i at the specified index.

Input

The input contains one integer ii, the required sequence index.

Output

Print one integer: xix_i modulo 1 000 0001\,000\,000.

Subtasks

  • Subtask 1 (20 points): 0≤i≤1000\le i\le 100.
  • Subtask 2 (30 points): 0≤i≤1050\le i\le 10^5.
  • Subtask 3 (50 points): 0≤i≤1060\le i\le 10^6.

Examples

Input

0

Output

1

Explanation

The sequence is initialized with x0=1x_0=1. Since the input is i=0i=0, the recurrence is unnecessary and the answer is 11.