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

3559번 - Jealous Numbers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB59302652.000%

문제

There is a trouble in Numberland, prime number $p$ is jealous of another prime number $q$. She thinks that there are more integer numbers between $a$ and $b,ドル inclusively, that are divisible by greater power of $q$ than that of $p$. Help $p$ to get rid of her feelings.

Let $\alpha(n, x)$ be maximal $k$ such that $n$ is divisible by $x^k$. Let us say that a number $n$ is $p$-dominating over~$q$ if $\alpha(n, p)>\alpha(n, q)$. Find out for how many numbers between $a$ and $b,ドル inclusive are $p$-dominating over~$q$.

입력

The first line of the input file contains $a,ドル $b,ドル $p$ and $q$ (1ドル \le a \le b \le 10^{18}$; 2ドル \le p, q \le 10^9$; $p \ne q$; $p$ and $q$ are prime).

출력

Output one number --- how many numbers $n$ between $a$ and $b,ドル inclusive, are $p$-dominating over $q$.

제한

예제 입력 1

1 20 3 2

예제 출력 1

4

힌트

In the given example 3, 9, 15 and 18 are 3-dominating over 2.

출처

ICPC > Regionals > Northern Eurasia > Northwestern Russia Regional Contest > NEERC Northern Subregional 2009 J번

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

출처

대학교 대회

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

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