A11133 | Winter is here
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Winter is here at the North and the White Walkers are close. John Snow has an army consisting of $n$ soldiers. While the rest of the world is fighting for the Iron Throne, he is going to get ready for the attack of the White Walkers.
He has created a method to know how strong his army is. Let the $i$ -th soldier’s strength be $a_{i}$ . For some $k$ he calls $i_{1},i_{2},...,i_{k}$ a clan if $i_{1}<i_{2}<i_{3}<...<i_{k}$ and $gcd(a_{i1},a_{i2},...,a_{ik})>1$ . He calls the strength of that clan $k·gcd(a_{i1},a_{i2},...,a_{ik})$ . Then he defines the strength of his army by the sum of strengths of all possible clans.
Your task is to find the strength of his army. As the number may be very large, you have to print it modulo $1000000007$ ( $10^{9}+7$ ).
Greatest common divisor (gcd) of a sequence of integers is the maximum possible integer so that each element of the sequence is divisible by it.
He has created a method to know how strong his army is. Let the $i$ -th soldier’s strength be $a_{i}$ . For some $k$ he calls $i_{1},i_{2},...,i_{k}$ a clan if $i_{1}<i_{2}<i_{3}<...<i_{k}$ and $gcd(a_{i1},a_{i2},...,a_{ik})>1$ . He calls the strength of that clan $k·gcd(a_{i1},a_{i2},...,a_{ik})$ . Then he defines the strength of his army by the sum of strengths of all possible clans.
Your task is to find the strength of his army. As the number may be very large, you have to print it modulo $1000000007$ ( $10^{9}+7$ ).
Greatest common divisor (gcd) of a sequence of integers is the maximum possible integer so that each element of the sequence is divisible by it.
输入格式
The first line contains integer $n$ ( $1<=n<=200000$ ) — the size of the army.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=1000000$ ) — denoting the strengths of his soldiers.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $1<=a_{i}<=1000000$ ) — denoting the strengths of his soldiers.
输出格式
Print one integer — the strength of John Snow's army modulo $1000000007$ ( $10^{9}+7$ ).
输入输出样例
输入 #1
3 3 3 1
输出 #1
12
输入 #2
4 2 3 4 6
输出 #2
39
In the first sample the clans are ${1},{2},{1,2}$ so the answer will be $1·3+1·3+2·3=12$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted