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

18694번 - Game of Nim Everywhere 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB90412939.189%

문제

Yes, this game comes again and again. Nim is a mathematical game of strategy in which two players take turns removing objects from distinct heaps. On each turn, a player must remove at least one object, and may remove any number of objects provided they all come from the same heap. The winner of the game is the player who removes the last object.

In this problem we will play with only 3 heaps, and the initial state also will be special, it will always be in the following format (N, 2 × N, 3 × N) where N is a positive integer. For example if N is 3, the 3 heaps will initially start with 3, 6 and 9 objects.

A winning state is a state of the heaps where there’s always a strategy for the player who is about to play, to win the game regardless what the other player does.

In this problem you are given two integers L and R, and your task is to find how many different values for N (L ≤ N ≤ R) such that if we use N to get the initial state as described above, it will be a winning state for the first player.

입력

Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 105) representing the number of test cases. Followed by T test cases.

Each test case will be just one line containing 2 integers separated by a space, L and R (1 ≤ L ≤ R ≤ 261), which are the range as described above.

출력

For each test case, print a single line with the number of different values of N which satisfy the condition described above.

제한

예제 입력 1

2
1 5
10 1000

예제 출력 1

1
854

힌트

In the first test case, the only value for N which gives a winning state is 3, the state will be (3, 6, 9).

출처

ICPC > Regionals > Africa and Arab > Arab Collegiate Programming Contest > 2017 Arab Collegiate Programming Contest B번

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

출처

대학교 대회

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

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