CF1436F.Sum Over Subsets

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

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

  • BAB \subset A ;
  • B=A1|B| = |A| - 1 ;
  • greatest common divisor of all elements in AA is equal to one;

find the sum of xAxxBx\sum_{x \in A}{x} \cdot \sum_{x \in B}{x} , modulo 998244353998\,244\,353 .

输入格式

The first line contains one integer mm ( 1m1051 \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 ( 1ai105,1freqi1091 \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.

输出格式

Print the required sum, modulo 998244353998\,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.

ABA \subset B : Set AA is a subset of a set BB .

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

首页