CF1436F.Sum Over Subsets

省选/NOI-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a multiset SS. Over all pairs of subsets AA and BB, such that:

  • B⊂AB \subset A;
  • ∣B∣=∣A∣−1|B| = |A| - 1;
  • greatest common divisor of all elements in AA is equal to one;

find the sum of ∑x∈Ax⋅∑x∈Bx\sum_{x \in A}{x} \cdot \sum_{x \in B}{x}, modulo 998 244 353998\,244\,353.

给你一个多重集 SS。对所有满足以下条件的子集对 AA 和 BB:

  • B⊂AB \subset A;
  • ∣B∣=∣A∣−1|B| = |A| - 1;
  • AA 中所有元素的最大公约数为 11;

求 ∑x∈Ax⋅∑x∈Bx\sum_{x \in A}{x} \cdot \sum_{x \in B}{x} 的总和,并对 998 244 353998\,244\,353 取模。

输入格式

The first line contains one integer mm (1≤m≤1051 \le m \le 10^5): the number of different values in the multiset SS.

Each of the next mm lines contains two integers aia_i, freqifreq_i (1≤ai≤105,1≤freqi≤1091 \le a_i \le 10^5, 1 \le freq_i \le 10^9). Element aia_i appears in the multiset SS freqifreq_i times. All aia_i are different.

第一行包含一个整数 mm(1≤m≤1051 \le m \le 10^5):多重集 SS 中不同元素的个数。

接下来的 mm 行,每行包含两个整数 aia_i 和 freqifreq_i(1≤ai≤1051 \le a_i \le 10^5,1≤freqi≤1091 \le freq_i \le 10^9)。元素 aia_i 在多重集 SS 中出现 freqifreq_i 次。所有 aia_i 互不相同。

输出格式

Print the required sum, modulo 998 244 353998\,244\,353.

输出所需的和,对 998 244 353998\,244\,353 取模。

输入输出样例

  • 输入#1

    2
    1 1
    2 1

    输出#1

    9
  • 输入#2

    4
    1 1
    2 1
    3 1
    6 1

    输出#2

    1207
  • 输入#3

    1
    1 5

    输出#3

    560

说明/提示

A multiset is a set where elements are allowed to coincide. ∣X∣|X| is the cardinality of a set XX, the number of elements in it.

A⊂BA \subset B: Set AA is a subset of a set BB.

In the first example B=1,A=1,2B={1}, A={1,2} and B=2,A=1,2B={2}, A={1, 2} have a product equal to 1⋅3+2⋅3=91\cdot3 + 2\cdot3=9. Other pairs of AA and BB don't satisfy the given constraints.

多重集是一种允许元素重复的集合。∣X∣|X| 表示集合 XX 的基数,即其中元素的个数。

A⊂BA \subset B:集合 AA 是集合 BB 的子集。

在第一个例子中,B={1},A={1,2}B=\{1\}, A=\{1,2\} 和 B={2},A={1,2}B=\{2\}, A=\{1, 2\} 这两对集合的乘积为 1⋅3+2⋅3=91\cdot3 + 2\cdot3=9。其余的 AA 与 BB 组合均不满足给定约束条件。

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

首页