CF1559E.Mocha and Stars

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

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 (1≤i≤n1\le i\le n), aia_i is an integer in the range [li,ri][l_i, r_i].
  • ∑i=1nai≤m\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 998 244 353998\,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 (1≤i≤n1\le i\le n) such that ai≠bia_i \ne b_i.

Mocha 想成为一名占星师。在浙江可以看到 nn 颗星星,其中第 ii 颗星星的亮度为 aia_i。

Mocha 认为这 nn 颗星星构成了一组星座,她用 (a1,a2,…,an)(a_1,a_2,\ldots,a_n) 表示其状态。若一个状态满足以下三个条件,则称其为数学的(mathematical):

  • 对所有 ii(1≤i≤n1\le i\le n),aia_i 是区间 [li,ri][l_i, r_i] 内的一个整数;
  • ∑i=1nai≤m\sum \limits _{i=1} ^ n a_i \le m;
  • gcd⁡(a1,a2,…,an)=1\gcd(a_1,a_2,\ldots,a_n)=1。

其中,gcd⁡(a1,a2,…,an)\gcd(a_1,a_2,\ldots,a_n) 表示整数 a1,a2,…,ana_1,a_2,\ldots,a_n 的最大公约数(GCD)。

Mocha 想知道该星座共有多少种不同的数学状态。由于答案可能很大,你必须输出其对 998 244 353998\,244\,353 取模的结果。

两个状态 (a1,a2,…,an)(a_1,a_2,\ldots,a_n) 和 (b1,b2,…,bn)(b_1,b_2,\ldots,b_n) 被视为不同,当且仅当存在某个 ii(1≤i≤n1\le i\le n)使得 ai≠bia_i \ne b_i。

输入格式

The first line contains two integers nn and mm (2≤n≤502 \le n \le 50, 1≤m≤1051 \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 (1≤li≤ri≤m1 \le l_i \le r_i \le m) — the range of the brightness of the ii-th star.

第一行包含两个整数 nn 和 mm(2≤n≤502 \le n \le 50,1≤m≤1051 \le m \le 10^5)—— 分别表示星星的数量以及星星亮度总和的上界。

接下来的 nn 行中,每行包含两个整数 lil_i 和 rir_i(1≤li≤ri≤m1 \le l_i \le r_i \le m)—— 表示第 ii 颗星星亮度的取值范围。

输出格式

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

输出一个整数——该星座的不同数学状态的数量,对 998 244 353998\,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.

在第一个例子中,该构型共有 44 种不同的数学状态:

  • 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。

输入解题思路,AI测评打分。不知道怎么写?

首页