#P1865. A % B Problem

    ID: 817 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>搜索洛谷原创素数判断,质数,筛法前缀和

A % B Problem

Description

Given l,rl, r, find the number of primes in the interval [l,r][l, r].

Input Format

The first line contains two integers, the number of queries nn and the maximum value of the right endpoint mm.
Then follow nn lines, each with two integers l,rl, r, representing one query.

Output Format

For each query, output one line. If l,r[1,m]l, r \in [1, m], output the number of primes in the interval; otherwise, output Crossing the line.

2 5
1 3
2 6
2
Crossing the line

Hint

Constraints

  • For 20%20\% of the testdata, n,m10n, m \le 10.
  • For 100%100\% of the testdata, 1n10001 \le n \le 1000, 1m1061 \le m \le 10^6, 109lr109-10^9 \le l \le r \le 10^9.

Translated by ChatGPT 5