CF1559E.Mocha and Stars

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Mocha wants to be an astrologer. There are nn stars which can be seen in Zhijiang, and the brightness of the ii -th star is aia_i .

Mocha considers that these nn stars form a constellation, and she uses (a1,a2,,an)(a_1,a_2,\ldots,a_n) to show its state. A state is called mathematical if all of the following three conditions are satisfied:

  • For all ii ( 1in1\le i\le n ), aia_i is an integer in the range [li,ri][l_i, r_i] .
  • i=1naim\sum \limits _{i=1} ^ n a_i \le m .
  • gcd(a1,a2,,an)=1\gcd(a_1,a_2,\ldots,a_n)=1 .

Here, gcd(a1,a2,,an)\gcd(a_1,a_2,\ldots,a_n) denotes the greatest common divisor (GCD) of integers a1,a2,,ana_1,a_2,\ldots,a_n .

Mocha is wondering how many different mathematical states of this constellation exist. Because the answer may be large, you must find it modulo 998244353998\,244\,353 .

Two states (a1,a2,,an)(a_1,a_2,\ldots,a_n) and (b1,b2,,bn)(b_1,b_2,\ldots,b_n) are considered different if there exists ii ( 1in1\le i\le n ) such that aibia_i \ne b_i .

输入格式

The first line contains two integers nn and mm ( 2n502 \le n \le 50 , 1m1051 \le m \le 10^5 ) — the number of stars and the upper bound of the sum of the brightness of stars.

Each of the next nn lines contains two integers lil_i and rir_i ( 1lirim1 \le l_i \le r_i \le m ) — the range of the brightness of the ii -th star.

输出格式

Print a single integer — the number of different mathematical states of this constellation, modulo 998244353998\,244\,353 .

输入输出样例

  • 输入#1

    2 4
    1 3
    1 2

    输出#1

    4
  • 输入#2

    5 10
    1 10
    1 10
    1 10
    1 10
    1 10

    输出#2

    251
  • 输入#3

    5 100
    1 94
    1 96
    1 91
    4 96
    6 97

    输出#3

    47464146

说明/提示

In the first example, there are 44 different mathematical states of this constellation:

  • a1=1a_1=1 , a2=1a_2=1 .
  • a1=1a_1=1 , a2=2a_2=2 .
  • a1=2a_1=2 , a2=1a_2=1 .
  • a1=3a_1=3 , a2=1a_2=1 .
首页