CF1436F.Sum Over Subsets
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a multiset S. Over all pairs of subsets A and B, such that:
- B⊂A;
- ∣B∣=∣A∣−1;
- greatest common divisor of all elements in A is equal to one;
find the sum of ∑x∈Ax⋅∑x∈Bx, modulo 998244353.
给你一个多重集 S。对所有满足以下条件的子集对 A 和 B:
- B⊂A;
- ∣B∣=∣A∣−1;
- A 中所有元素的最大公约数为 1;
求 ∑x∈Ax⋅∑x∈Bx 的总和,并对 998244353 取模。
输入格式
The first line contains one integer m (1≤m≤105): the number of different values in the multiset S.
Each of the next m lines contains two integers ai, freqi (1≤ai≤105,1≤freqi≤109). Element ai appears in the multiset S freqi times. All ai are different.
第一行包含一个整数 m(1≤m≤105):多重集 S 中不同元素的个数。
接下来的 m 行,每行包含两个整数 ai 和 freqi(1≤ai≤105,1≤freqi≤109)。元素 ai 在多重集 S 中出现 freqi 次。所有 ai 互不相同。
输出格式
Print the required sum, modulo 998244353.
输出所需的和,对 998244353 取模。
输入输出样例
输入#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∣ is the cardinality of a set X, the number of elements in it.
A⊂B: Set A is a subset of a set B.
In the first example B=1,A=1,2 and B=2,A=1,2 have a product equal to 1⋅3+2⋅3=9. Other pairs of A and B don't satisfy the given constraints.
多重集是一种允许元素重复的集合。∣X∣ 表示集合 X 的基数,即其中元素的个数。
A⊂B:集合 A 是集合 B 的子集。
在第一个例子中,B={1},A={1,2} 和 B={2},A={1,2} 这两对集合的乘积为 1⋅3+2⋅3=9。其余的 A 与 B 组合均不满足给定约束条件。
输入解题思路,AI测评打分。不知道怎么写?