Logo
(追記) (追記ここまで)

21121번 - Brave Seekers of Unicorns 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB44332875.676%

문제

You are a member of the Brave Seekers of Unicorns (BSU), the secret magical order. The BSU is fond of seeking unicorns. Recently, they have agreed to call an array $a_1, a_2, \ldots, a_k$ of $k$ integers a unicorn if it satisfies the following conditions:

  • the array is not empty ($k > 0$);
  • there are no three consecutive elements with their bitwise XOR equal to zero ($a_i \oplus a_{i+1} \oplus a_{i+2} \ne 0$ for all 1ドル \le i \le k - 2$);
  • the array is strictly increasing ($a_i < a_{i+1}$ for all 1ドル \le i \le k - 1$);
  • the elements of the array are integers between 1ドル$ to $n,ドル inclusively (1ドル \le a_i \le n$ for all 1ドル \le i \le k$).

For example, if $n = 10,ドル then the array $[1, 4, 5, 9]$ is not a unicorn because 1ドル \oplus 4 \oplus 5 = 0,ドル but the array $[2, 4, 7, 9]$ is a unicorn.

The Grand Master of the BSU has commanded you to calculate the number of unicorns. Since the number can be pretty large, you must compute it modulo 998ドル,244円,353円$.

입력

The only line contains an integer $n$ (1ドル \le n \le 10^6$).

출력

Print the number of unicorns modulo 998ドル,244円,353円$.

제한

예제 입력 1

1

예제 출력 1

1

예제 입력 2

2

예제 출력 2

3

예제 입력 3

3

예제 출력 3

6

예제 입력 4

5

예제 출력 4

26

예제 입력 5

322

예제 출력 5

782852421

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud C번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /