Masala #M080C

Xotira 130 MB Vaqt 2000 ms Qiyinchiligi 40 %
14

  

Degrees

Find the number of integers lying on the interval [A,B] that can be represented as the sum of exactly Y distinct powers of an integer X, where both X and the powers are integers.

For example, for A=15, B=20, Y=2, and X=2, the answer is 3 because:

\(17=2^4+2^0\)

\(18=2^4+2^1\)

\(20=2^4+2^2\)


Kiruvchi ma'lumotlar:

The first line contains two integers A and B \((1 <= A <= B <= 2^{31} - 1)\). The next two lines contain integers \(Y\) and \(X\) \((1 <= Y <= 20, 2 <= X <= 10)\)


Chiquvchi ma'lumotlar:

Print a single integer - the answer to the problem.


Misollar
# input.txt output.txt
1
15 20
2
2
3
Yechimini yuborish
Bu amalni bajarish uchun tizimga kiring, agar profilingiz bo'lmasa istalgan payt ro'yxatdan o'tishingiz mumkin