CF1436F.Sum Over Subsets
普及/提高-
通过率:0%
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 .
输入格式
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.
输出格式
Print the required sum, modulo 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.