CF1350B.Orac and Models

普及/提高-

通过率:0%

时间限制:3.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

There are nn models in the shop numbered from 11 to nn, with sizes s1,s2,…,sns_1, s_2, \ldots, s_n.

Orac will buy some of the models and will arrange them in the order of increasing numbers (i.e. indices, but not sizes).

Orac thinks that the obtained arrangement is beatiful, if for any two adjacent models with indices iji_j and ij+1i_{j+1} (note that ij<ij+1i_j \lt i_{j+1}, because Orac arranged them properly), ij+1i_{j+1} is divisible by iji_j and sij<sij+1s_{i_j} \lt s_{i_{j+1}}.

For example, for 66 models with sizes 3,6,7,7,7,7{3, 6, 7, 7, 7, 7}, he can buy models with indices 11, 22, and 66, and the obtained arrangement will be beautiful. Also, note that the arrangement with exactly one model is also considered beautiful.

Orac wants to know the maximum number of models that he can buy, and he may ask you these queries many times.

商店中有 nn 个编号为 11 到 nn 的模型,其尺寸分别为 s1,s2,…,sns_1, s_2, \ldots, s_n。

Orac 将购买其中若干模型,并按编号(即下标,而非尺寸)升序排列。

Orac 认为所得到的排列是优美的,当且仅当对任意两个相邻模型(其编号分别为 iji_j 和 ij+1i_{j+1},注意由于 Orac 是按编号升序排列的,故必有 ij<ij+1i_j \lt i_{j+1}),均满足:ij+1i_{j+1} 能被 iji_j 整除,且 sij<sij+1s_{i_j} \lt s_{i_{j+1}}。

例如,对于 66 个尺寸为 3,6,7,7,7,7{3, 6, 7, 7, 7, 7} 的模型,Orac 可以购买编号为 11、22 和 66 的模型,所得排列即为优美的。另外请注意,仅含一个模型的排列也被视为优美的。

Orac 想知道他最多能购买多少个模型;他可能会多次向你提出此类查询。

输入格式

The first line contains one integer t (1≤t≤100)t\ (1 \le t\le 100): the number of queries.

Each query contains two lines. The first line contains one integer n (1≤n≤100 000)n\ (1\le n\le 100\,000): the number of models in the shop, and the second line contains nn integers s1,…,sn (1≤si≤109)s_1,\dots,s_n\ (1\le s_i\le 10^9): the sizes of models.

It is guaranteed that the total sum of nn is at most 100 000100\,000.

第一行包含一个整数 t (1≤t≤100)t\ (1 \le t\le 100):查询次数。

每次查询包含两行。第一行包含一个整数 n (1≤n≤100 000)n\ (1\le n\le 100\,000):商店中模型的数量;第二行包含 nn 个整数 s1,…,sn (1≤si≤109)s_1,\dots,s_n\ (1\le s_i\le 10^9):各模型的尺寸。

保证所有查询中 nn 的总和不超过 100 000100\,000。

输出格式

Print tt lines, the ii-th of them should contain the maximum number of models that Orac can buy for the ii-th query.

输出 tt 行,其中第 ii 行应包含 Orac 在第 ii 个查询中最多能购买的模型数量。

输入输出样例

  • 输入#1

    4
    4
    5 3 4 6
    7
    1 4 2 3 6 4 9
    5
    5 4 3 2 1
    1
    9

    输出#1

    2
    3
    1
    1

说明/提示

In the first query, for example, Orac can buy models with indices 22 and 44, the arrangement will be beautiful because 44 is divisible by 22 and 66 is more than 33. By enumerating, we can easily find that there are no beautiful arrangements with more than two models.

In the second query, Orac can buy models with indices 11, 33, and 66. By enumerating, we can easily find that there are no beautiful arrangements with more than three models.

In the third query, there are no beautiful arrangements with more than one model.

在第一次查询中,例如,Orac 可以购买索引为 22 和 44 的模型,该排列是优美的,因为 44 能被 22 整除,且 66 大于 33。通过枚举,我们可以轻易发现:不存在包含超过两个模型的优美排列。

在第二次查询中,Orac 可以购买索引为 11、33 和 66 的模型。通过枚举,我们可以轻易发现:不存在包含超过三个模型的优美排列。

在第三次查询中,不存在包含超过一个模型的优美排列。

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

首页