A8191 | Petya and Divisors
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Little Petya loves looking for numbers' divisors. One day Petya came across the following problem:
You are given $n$ queries in the form " $x_{i}$ $y_{i}$ ". For each query Petya should count how many divisors of number $x_{i}$ divide none of the numbers $x_{i-yi},x_{i-yi}+1,...,x_{i-1}$ . Help him.
You are given $n$ queries in the form " $x_{i}$ $y_{i}$ ". For each query Petya should count how many divisors of number $x_{i}$ divide none of the numbers $x_{i-yi},x_{i-yi}+1,...,x_{i-1}$ . Help him.
输入格式
The first line contains an integer $n$ ( $1<=n<=10^{5}$ ). Each of the following $n$ lines contain two space-separated integers $x_{i}$ and $y_{i}$ ( $1<=x_{i}<=10^{5}$ , $0<=y_{i}<=i-1$ , where $i$ is the query's ordinal number; the numeration starts with $1$ ).
If $y_{i}=0$ for the query, then the answer to the query will be the number of divisors of the number $x_{i}$ . In this case you do not need to take the previous numbers $x$ into consideration.
If $y_{i}=0$ for the query, then the answer to the query will be the number of divisors of the number $x_{i}$ . In this case you do not need to take the previous numbers $x$ into consideration.
输出格式
For each query print the answer on a single line: the number of positive integers $k$ such that 
输入输出样例
输入 #1
6 4 0 3 1 5 2 6 2 18 4 10000 3
输出 #1
3 1 1 2 2 22
Let's write out the divisors that give answers for the first 5 queries:
1\) 1, 2, 4
2\) 3
3\) 5
4\) 2, 6
5\) 9, 18
1\) 1, 2, 4
2\) 3
3\) 5
4\) 2, 6
5\) 9, 18
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted