链接:https://codeforces.ml/contest/1350/problem/B

There are nn models in the shop numbered from 11 to nn, with sizes s1,s2,…,sns1,s2,…,sn.

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 ijij and ij+1ij+1 (note that ij<ij+1ij<ij+1, because Orac arranged them properly), ij+1ij+1 is divisible by ijij and sij<sij+1sij<sij+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.

Input

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

Each query contains two lines. The first line contains one integer n (1≤n≤100000)n (1≤n≤100000): the number of models in the shop, and the second line contains nn integers s1,…,sn (1≤si≤109)s1,…,sn (1≤si≤109): the sizes of models.

It is guaranteed that the total sum of nn is at most 100000100000.

Output

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

Example

input

Copy

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

output

Copy

2
3
1
1

Note

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.

代码:

#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
#include<cstdlib>
#include<cmath>
#include<stack>
#include<map>
#include<algorithm>
using namespace std;
#define ll long long
#define lb long double
#define INF 0x3f3f3f3f
#define maxn 200010
ll n,k,l,t,x,s;
ll a[200001];
ll dp[100001];
vector<ll>m[100001];
int main()
{cin>>t;for(int i=2;i<=100000;i++){x=sqrt(i);for(int j=1;j<=x;j++){if(i%j==0){m[i].push_back(j);if(j*j!=i&&j!=1)m[i].push_back(i/j);}}}while(t--){cin>>n;for(int i=1;i<=n;i++){cin>>a[i];dp[i]=1;}s=1;for(int i=2;i<=n;i++){for(int j=0;j<m[i].size();j++){//cout<<m[i][j]<<" ";if(a[i]>a[m[i][j]])dp[i]=max(dp[i],dp[m[i][j]]+1);}//cout<<endl;s=max(s,dp[i]);}cout<<s<<endl;}
}

B. Orac and Models相关推荐

  1. 1350B. Orac and Models

    B. Orac and Models:题目 题意:找一个最长的串,后一个下标可以整除前一个,并且a[i]<a[i+1] #include <bits/stdc++.h> using ...

  2. CodeForces - 1350B Orac and Models(dp)

    题目链接:点击查看 题目大意:给出一个长度为 n 的数列,求出最长上升子序列的长度,满足前一个的下标是后一个下标的因子 题目分析:读懂题后不难发现这是 n * n 最长不下降子序列模板题目的变形题,只 ...

  3. B. Orac and Models(cf)dp

    原题链接:Problem - 1350B - Codeforces 题意: 求一个下标单调递增且互为倍数,即满足j > i且j为i的倍数,并且s[i] < s[j]的最长子序列. 其实和最 ...

  4. codeforces 1350.Div2 A-D Orac and xxx

    目录 A.Orac and Fac 1:问题描述 2:问题分析: 3:代码: B.Orac and Models 1:问题描述 2:问题分析: 3:代码 C.Orac and LCM 1:问题描述 2 ...

  5. Codeforces Round #641 (Div. 2)A~E题解(数论场)

    题目大意就是给你一个数执行k次操作,每次加上这个数的最小质因子(除了一以外)变成一个新的数,问最后的数是多少 解题思路:很明显如果一开始是偶数的话就会一直加2加2,如果是奇数的话先找到这个数的质因子一 ...

  6. 编译ONNX模型Compile ONNX Models

    编译ONNX模型Compile ONNX Models 本文是一篇介绍如何使用Relay部署ONNX模型的说明. 首先,必须安装ONNX包. 一个快速的解决方案是安装protobuf编译器,然后 pi ...

  7. Cannot find snapshot in models/VGGNet/VOC0712/SSD_300x300

    错误描述: 执行 python examples/ssd/ssd_pascal.py 报错: Cannot find snapshot in models/VGGNet/VOC0712/SSD_300 ...

  8. tensorflow models 工程解析

    项目地址:https://github.com/tensorflow/models 下面列表中的是否支持 tf2.0 来源于 https://github.com/tensorflow/models/ ...

  9. 三维植物树木模型 Maxtree – Plant Models Vol 74

    maxtree–工厂模型第74卷 大小解压后:2.34G 信息: 植物模型第74卷是高质量的三维植物模型的集合.包括12个物种,共72个单一模式. 获取地址:三维植物树木模型 Maxtree – Pl ...

最新文章

  1. java的移植性_详细介绍JAVA的可移植性
  2. Redis概述与Redis集群(一)
  3. 一段把mp4中的音频提取并保存在原目录的python脚本
  4. 中医科学院临基所携手第四范式助力抗疫工作
  5. Linux sqlplus权限不足,sqlplus登录用户提示权限不足
  6. alpine登陆mysql_如何构建一个php7-alpine的docker镜像
  7. Tomcat的bin文档下startup.bat启动后中文出现乱码
  8. 课文电子计算机与多媒体减写,课文电子计算机与多媒体关系介绍
  9. ORACLE 视图的 with check option
  10. 【Modern Robotics】 Mechanics, Planning and Control现代机器人学:机构、规划与控制
  11. 个人永久性免费-Excel催化剂功能第29波-追加中国特色的中文相关自定义函数
  12. Chrome 去掉“该网站的安全证书不受信任!”的提示
  13. VM安装win7系统一直失败,可能是镜像文件不对
  14. 若用MASM写操作系统的启动部分如何实现? 其他开发语言 / 汇编语言 - CSDN社区 community.csdn.net
  15. 艾宾浩斯遗忘曲线PHP,艾宾浩斯记忆遗忘曲线 复习计划表 网盘下载
  16. Java课程实验报告一:初识java
  17. 微信公众平台群发规则说明
  18. ListView高效率刷新
  19. 因为计算机丢失uxtheme.dll,解决Win10开机提示uxtheme.dll丢失的方法
  20. java源码系列:HashMap底层存储原理详解——4、技术本质-原理过程-算法-取模具体解决什么问题

热门文章

  1. 1399 最小生成树(Prim算法1)
  2. 计算机速录专业教学计划,速录师(五级)初级
  3. Android 录音工具AudioRecord使用
  4. ios获取4g_VSCO全滤镜解锁!安卓iOS都没问题!!赶紧下载!手慢拍大腿
  5. 你认识他吗:“鸟巢”的首席电工
  6. java对接移动物联网onenet平台实现接收设备上报数据命令下发
  7. 基于java Restful API 的Sdnote服务端开发笔记
  8. iOS-NSUserDefaults详解
  9. python做网站和php_做网站用php还是python
  10. 【2021最新版】Memcached面试题总结(24道题含答案解析)