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

19097번 - Primes 다국어인터랙티브

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 256 MB84181028.571%

문제

This is an interactive problem.

For two positive integers $x,y,ドル we define $\pi(x,y)$ to be the number of distinct primes that divide both $x$ and $y$. For example $\pi(2,3)=0,ドル $\pi(8,16)=1$ and $\pi(30,105)=2$.

For two positive integers $a,b,ドル where $a\leq b,ドル we define $S(a,b)$ to be the sum of values $\pi(x,y)$ over all pairs of integers $(x,y)$ satisfying $a\leq x < y\leq b$.

Your task is to compute the values $S(a,b)$ for many query pairs $(a,b)$. To make your task more challenging, all the queries have to be answered online.

입력

The first line of the input contains a single integer $q$ (1ドル\leq q\leq 5\cdot 10^4$), denoting the number of queries. The next $q$ lines describe the queries. The $i$-th of these lines contains two integers $a_i,b_i$ (1ドル\leq a_i\leq b_i\leq 10^6$).

Note that the $i$-the query ($i\geq 2$) will be available at the input only after you output the answer to the $(i-1)$-th query.

출력

You should print exactly $q$ lines. The $i$-th of these lines should contain the value $S(a_i,b_i)$.

Do not forget to flush the output after answering each query.

제한

예제 입력 1

4
1 5
6 6
3 9
1 500000

예제 출력 1

1
0
6
56529651093

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2017 > Day 6: Warsaw U Contest, XVII OpenCup Onsite H번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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