A13767 | Sum Over Subsets
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a multiset $S$ . Over all pairs of subsets $A$ and $B$ , such that:
- $B \subset A$ ;
- $|B| = |A| - 1$ ;
- greatest common divisor of all elements in $A$ is equal to one;
find the sum of $\sum_{x \in A}{x} \cdot \sum_{x \in B}{x}$ , modulo $998\,244\,353$ .
- $B \subset A$ ;
- $|B| = |A| - 1$ ;
- greatest common divisor of all elements in $A$ is equal to one;
find the sum of $\sum_{x \in A}{x} \cdot \sum_{x \in B}{x}$ , modulo $998\,244\,353$ .
输入格式
The first line contains one integer $m$ ( $1 \le m \le 10^5$ ): the number of different values in the multiset $S$ .
Each of the next $m$ lines contains two integers $a_i$ , $freq_i$ ( $1 \le a_i \le 10^5, 1 \le freq_i \le 10^9$ ). Element $a_i$ appears in the multiset $S$ $freq_i$ times. All $a_i$ are different.
Each of the next $m$ lines contains two integers $a_i$ , $freq_i$ ( $1 \le a_i \le 10^5, 1 \le freq_i \le 10^9$ ). Element $a_i$ appears in the multiset $S$ $freq_i$ times. All $a_i$ are different.
输出格式
Print the required sum, modulo $998\,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|$ is the cardinality of a set $X$ , the number of elements in it.
$A \subset 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\cdot3 + 2\cdot3=9$ . Other pairs of $A$ and $B$ don't satisfy the given constraints.
$A \subset 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\cdot3 + 2\cdot3=9$ . Other pairs of $A$ and $B$ don't satisfy the given constraints.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted