CF111B.Petya and Divisors

普及+/提高

通过率:0%

时间限制:5.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

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 - y__i, x__i - y__i + 1, ..., x__i - 1. Help him.

小Petya喜欢寻找一个数的约数。一天,Petya遇到了如下问题:

给定 nn 个查询,每个查询的形式为 “xix_i yiy_i”。对于每个查询,Petya需要计算:xix_i 的约数中,有多少个不整除下列任意一个数:xi−yi, xi−yi+1, …, xi−1x_i - y_i,\ x_i - y_i + 1,\ \dots,\ x_i - 1。请帮助他。

输入格式

The first line contains an integer n (1 ≤ n ≤ 105). Each of the following n lines contain two space-separated integers x__i and y__i (1 ≤ x__i ≤ 105, 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.

第一行包含一个整数 nn(1 ≤ n ≤ 1051 ≤ n ≤ 10^5)。接下来的 nn 行中,每行包含两个以空格分隔的整数 xix_i 和 yiy_i(1 ≤ xi ≤ 1051 ≤ x_i ≤ 10^5,0 ≤ yi ≤ i − 10 ≤ y_i ≤ i - 1,其中 ii 是该查询的序号,编号从 1 开始)。

若某次查询中 yi = 0y_i = 0,则该查询的答案为 xix_i 的约数个数。此时无需考虑之前出现过的 xx 值。

输出格式

For each query print the answer on a single line: the number of positive integers k such that

对于每个查询,在单独一行输出答案:满足 的正整数 k 的个数。

输入输出样例

  • 输入#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

我们写出前 5 个查询的答案所对应的因数:

  1. 1, 2, 4

  2. 3

  3. 5

  4. 2, 6

  5. 9, 18

输入解题思路,AI测评打分。不知道怎么写?

首页