RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
COCI00174

Hrpa

Platinum I 플래티넘 I
난이도
1s
시간 제한
128MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Mirko and Slavko's favourite pastime is competing against each other in mathematical games. This time they took a heap of \(N\) pebbles and settled on the following rules:

  1. Mirko is the first to play, then Slavko, then Mirko again, then Slavko and so on;
  2. Mirko can take any number of pebbles (between \(1\) and \(N\), inclusive) from the heap during his first move;
  3. In each of the following turns the current player must take at least \(1\) pebble and is allowed to take at most double the amount of pebbles taken during the previous turn by the other player; naturally, one cannot take more pebbles than the remaining amount in the heap;
  4. The player who takes the last pebble is the winner.

Both Mirko and Slavko play optimally (if it is possible for one player to beat the other, that player will always win). We need to find the minimum number of pebbles that Mirko must take during his first turn such that he is guaranteed to win the game.

제약
입력 형식

The first and only line of input contains the positive integer \(N\) (\(2 \le N \le 10^{15}\)), the number of pebbles in the starting heap.

출력 형식

The first and only line of output must contain the required minimum number of pebbles that Mirko needs to remove during his first turn.

First sample description: Mirko has \(4\) possibilities to choose from: he can take \(1\), \(2\), \(3\), or \(4\) pebbles from the heap. If he takes all \(4\) pebbles he will naturally win, but that is not the minimum solution. If Mirko takes only one pebble, Slavko is left with a heap of \(3\), but he can take at most \(2\). Slavko cannot take all pebbles, but Mirko will be able to take all remaining pebbles during his next turn, winning the game. We conclude that \(1\) is the minimum solution for this test case.

서브태스크
서브태스크점수설명

Test 1

10점

None

Test 2

10점

None

Test 3

10점

None

Test 4

10점

None

Test 5

10점

None

Test 6

10점

None

Test 7

10점

None

Test 8

10점

None

Test 9

10점

None

Test 10

10점

None

예제 1
입력
4
출력
1
예제 2
입력
7
출력
2
예제 3
입력
8
출력
8
문제 정보

riseoj 작성

출처 COCI 2010/2011 Contest 4

평가 및 의견

Hrpa

개요
출제자 난이도 Platinum I 플래티넘 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Hrpa

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8