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

문제

We call the k-binary number a natural number which has in its binary representation exactly k digits of 1. For example, the 23 is a 4-binary number because the binary representation is 10111 and contains 4 digits of 1.

Given the N and k values, calculate the sum S of all k-binary numbers which are strictly lower than N. Because the sum is very large, you have to calculate modulo 1234567.

입력

The standard input contains the values N and k separated by a single space.

출력

The standard output will contain the number S modulo 1234567.

제한

  • 2 ≤ N ≤ 1015
  • 0 ≤ K ≤ 50

서브태스크

번호배점제한
130

N ≤ 106

230

106 < N ≤ 109 and k ≤ 7

340

109 < N ≤ 1015 and k ≤ 50

예제 입력 1

15 3

예제 출력 1

45

힌트

  • 1 – 1
  • 2 – 10
  • 3 – 11
  • 4 – 100
  • 5 – 101
  • 6 – 110
  • 7 – 111
  • 8 – 1000
  • 9 – 1001
  • 10 – 1010
  • 11 – 1011
  • 12 – 1100
  • 13 – 1101
  • 14 – 1110

S=7+11+13+14=45

채점 및 기타 정보

  • 예제는 채점하지 않는다.