CF1559E.Mocha and Stars
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mocha wants to be an astrologer. There are n stars which can be seen in Zhijiang, and the brightness of the i-th star is ai.
Mocha considers that these n stars form a constellation, and she uses (a1,a2,…,an) to show its state. A state is called mathematical if all of the following three conditions are satisfied:
- For all i (1≤i≤n), ai is an integer in the range [li,ri].
- i=1∑nai≤m.
- gcd(a1,a2,…,an)=1.
Here, gcd(a1,a2,…,an) denotes the greatest common divisor (GCD) of integers a1,a2,…,an.
Mocha is wondering how many different mathematical states of this constellation exist. Because the answer may be large, you must find it modulo 998244353.
Two states (a1,a2,…,an) and (b1,b2,…,bn) are considered different if there exists i (1≤i≤n) such that ai=bi.
Mocha 想成为一名占星师。在浙江可以看到 n 颗星星,其中第 i 颗星星的亮度为 ai。
Mocha 认为这 n 颗星星构成了一组星座,她用 (a1,a2,…,an) 表示其状态。若一个状态满足以下三个条件,则称其为数学的(mathematical):
- 对所有 i(1≤i≤n),ai 是区间 [li,ri] 内的一个整数;
- i=1∑nai≤m;
- gcd(a1,a2,…,an)=1。
其中,gcd(a1,a2,…,an) 表示整数 a1,a2,…,an 的最大公约数(GCD)。
Mocha 想知道该星座共有多少种不同的数学状态。由于答案可能很大,你必须输出其对 998244353 取模的结果。
两个状态 (a1,a2,…,an) 和 (b1,b2,…,bn) 被视为不同,当且仅当存在某个 i(1≤i≤n)使得 ai=bi。
输入格式
The first line contains two integers n and m (2≤n≤50, 1≤m≤105) — the number of stars and the upper bound of the sum of the brightness of stars.
Each of the next n lines contains two integers li and ri (1≤li≤ri≤m) — the range of the brightness of the i-th star.
第一行包含两个整数 n 和 m(2≤n≤50,1≤m≤105)—— 分别表示星星的数量以及星星亮度总和的上界。
接下来的 n 行中,每行包含两个整数 li 和 ri(1≤li≤ri≤m)—— 表示第 i 颗星星亮度的取值范围。
输出格式
Print a single integer — the number of different mathematical states of this constellation, modulo 998244353.
输出一个整数——该星座的不同数学状态的数量,对 998244353 取模。
输入输出样例
输入#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 4 different mathematical states of this constellation:
- a1=1, a2=1.
- a1=1, a2=2.
- a1=2, a2=1.
- a1=3, a2=1.
在第一个例子中,该构型共有 4 种不同的数学状态:
- a1=1,a2=1。
- a1=1,a2=2。
- a1=2,a2=1。
- a1=3,a2=1。
输入解题思路,AI测评打分。不知道怎么写?