当前位置: 首页 > news >正文

A - Orac and Models(最长上升子序列——加强版)

There are nn models in the shop numbered from 11 to nn, with sizes s_1, s_2, \ldots, s_ns1​,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 i_jij​ and i_{j+1}ij+1​ (note that i_j < i_{j+1}ij​<ij+1​, because Orac arranged them properly), i_{j+1}ij+1​ is divisible by i_jij​ and s_{i_j} < s_{i_{j+1}}sij​​<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 \le t\le 100)t (1≤t≤100): the number of queries.

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

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

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.

Sample 1

InputcopyOutputcopy
4
4
5 3 4 6
7
1 4 2 3 6 4 9
5
5 4 3 2 1
1
9
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.、、

题目翻译:

给出n个数的值,求出满足下标j整除i并且a[j]>a[i]的最多个数(j>i)

#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
#include<vector>
#include<cmath>
#include<cstdlib>using namespace std;
const int N = 1e5 + 10;int a[N],b[N];//DP:b[i]表示以i结尾的子序列的长度int main()
{int t; cin >> t;while (t--){int n; cin >> n;for (int i = 1; i <= n; i++) cin >> a[i]; //读入数据for (int i = 1; i <= n; i++) b[i] = 1;for (int i = 1; i <= n; i++)for (int j = 2 * i; j <= n; j += i) //满足条件1:j是i的倍数,j可以整除iif (a[i] < a[j]) b[j] = max(b[j], b[i] + 1); //满足条件2:a[j]>a[i]//DP:以选不选第j个数作为比较,求最大的那个//选j:长度为j的上一个数i加1,即b[i]+1;//不选j:即b[j]int ans = -INT_MAX;for (int i = 1; i <= n; i++) ans = max(ans, b[i]);cout << ans << endl;}}

相关文章:

A - Orac and Models(最长上升子序列——加强版)

There are nn models in the shop numbered from 11 to nn, with sizes s_1, s_2, \ldots, s_ns1​,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 obtai…...

【python手写算法】逻辑回归实现分类(含公式推导)

公式推导&#xff1a; 代码实现&#xff1a; # codingutf-8 import matplotlib.pyplot as plt import numpy as npdef f(w1,x1,w2,x2,b):zw1*x1w2*x2breturn 1/(1np.exp(-z)) if __name__ __main__:X1 [12.46, 0.25, 5.22, 11.3, 6.81, 4.59, 0.66, 14.53, 15.49, 14.43,2.1…...

【2023高教社杯数学建模国赛】ABCD题 问题分析、模型建立、参考文献及实现代码

【2023高教社杯数学建模国赛】ABCD题 问题分析、模型建立、参考文献及实现代码 1 比赛时间 北京时间&#xff1a;2023年9月7日 18:00-2023年9月10日20:00 2 思路内容 可以参考我提供的历史竞赛信息内容&#xff0c;最新更新我会发布在博客和知乎上&#xff0c;请关注我获得最…...

yum安装mysql5.7散记

## 数据源安装 $ yum -y install wget $ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm $ yum localinstall mysql57-community-release-el7-8.noarch.rpm $ yum repolist enabled | grep "mysql.*-community.*" $ yum install mysql-…...

DNS解析

1.DNS介绍 DNS 表示域名系统。此系统实质上是用于整理和识别各个域名的网络电话簿。电话簿将“Acme Pizza”之类的名称转换为要拨打的正确电话号码&#xff0c;而 DNS 将“www.google.com”之类的网络地址转换为托管该网站的计算机的物理 IP 地址&#xff0c;如“74.125.19.147…...

从jdk8 升级到jdk17的问题总结

目录 1. java.lang.reflect.InaccessibleObjectException: 2. java.lang.UnsatisfiedLinkError in autosys 3. java.lang.NoClassDefFoundError: Could not initialize class net.sf.jasperreports.engine.util.JRStyledTextParser 4. java.lang.UnsatisfiedLinkError: **…...

一百七十二、Flume——Flume采集Kafka数据写入HDFS中(亲测有效、附截图)

一、目的 作为日志采集工具Flume&#xff0c;它在项目中最常见的就是采集Kafka中的数据然后写入HDFS或者HBase中&#xff0c;这里就是用flume采集Kafka的数据导入HDFS中 二、各工具版本 &#xff08;一&#xff09;Kafka kafka_2.13-3.0.0.tgz &#xff08;二&#xff09;…...

pnpm 升级

1. 在以下路径下删除pnpm包 2. 执行which pnpm&#xff0c;在结果目录中删除pnpm 3. sudo npm install -g pnpm 重新安装&#xff0c;node默认使用16...

有关使用HttpServletRequest的Cookie的设置和获取

文章目录 小结问题和解决参考 小结 介绍了如何在HttpServletRequest中对Cookie的进行设置和获取。 问题和解决 在服务器端的HttpServletRequest中对Cookie的进行设置后&#xff0c;客户端在接下来的请求中会携带此设置好的Cookie&#xff0c;所以可以在服务器端接收请求时提…...

关于 Nginx 的哪些事

关于 Nginx 的哪些事 1、Nginx 主要功能2、Nginx 的常用命令2.1、启动Nginx2.2、停止 Nginx2.3、重新加载Nginx 配置2.4、检查Nginx配置文件2.5、指定配置文件2.6、检查Nginx版本2.7、显示Nginx帮助信息 3、Nginx 配置文件 nginx.conf3.1、Nginx 配置文件&#xff08;nginx.con…...

插入排序——希尔排序

1、简述&#xff1a; 希尔排序(Shells Sort)是插入排序的一种又称“缩小增量排序”&#xff08;Diminishing Increment Sort&#xff09;&#xff0c;是直接插入排序算法的一种更高效的改进版本。希尔排序是非稳定排序算法。该方法因 D.L.Shell 于 1959 年提出而得名。 希尔排…...

C语言之初阶总结篇

目录 NO.1 NO.2 NO.3 NO.4 NO.5 NO.6 NO.7 NO.8 NO.9 NO.10 NO.11 NO.12.概念tips NO.13.求最小公倍数 NO.14.最大公因数 NO.15.输入读取字符串 NO.16.倒置字符串 今天是一些C语言题目&#xff0c;最近天气炎热&#xff0c;多喝水。 NO.1 下面程序执行后&am…...

Android签名查看

查看签名文件信息 第一种方法&#xff1a; 1.打开cmd&#xff0c;执行keytool -list -v -keystore xxx.keystore&#xff0c;效果如下图&#xff1a; 第二种方法: 1.打开cmd&#xff0c;执行 keytool -list -v -keystore xxxx.keystore -storepass 签名文件密码&#xff0…...

Educational Codeforces Round 3

目录 A. USB Flash Drives B. The Best Gift C. Load Balancing D. Gadgets for dollars and pounds A. USB Flash Drives #include<bits/stdc.h>using namespace std; const int N1e65; typedef long long ll; typedef pair<ll,ll> pll; typedef array<int…...

Docker Compose常用命令

常用命令 1.1 restart, start, stop-- 启动和停止服务 命令必须在 docker-compose.yml文件所在的目录下执行。 # 前台启动, 启动项目中的所有服务。 $. docker-compose up# 后台启动, 启动所有服务并在后台运行。 $. docker-compose up -d# 停止所有服务。 $. docker-compose …...

C++——智能指针

智能指针 文章目录 智能指针内存泄漏智能指针解决内存泄漏问题智能指针的使用及原理RAII智能指针对象的拷贝问题 C中的智能指针auto_ptrunique_ptrshared_ptrweak_ptr定制包装器C11和boost中智能指针的关系 内存泄漏 什么是内存泄漏&#xff1a;内存泄漏指因为疏忽或错误造成程…...

CVE-2023-3836:大华智慧园区综合管理平台任意文件上传漏洞复现

文章目录 CVE-2023-3836&#xff1a;大华智慧园区综合管理平台任意文件上传漏洞复现0x01 前言0x02 漏洞描述0x03 影响范围0x04 漏洞环境0x05 漏洞复现1.访问漏洞环境2.构造POC3.复现 CVE-2023-3836&#xff1a;大华智慧园区综合管理平台任意文件上传漏洞复现 0x01 前言 免责声…...

LAMP搭建WordPress

L linux A apache hhtpd M mysql/maridb P PHP1、 安装php yum -y install php php-fpm php-server php-mysql1.1、 启动php-fpm并自启 systemctl enable php-fpm --now[rootecs-1cee ~]# systemctl status php-fpm ● php-fpm.service - The PHP FastCGI Process ManagerLoa…...

【数学建模竞赛】预测类赛题常用算法解析

解析常见的预测类算法 灰色预测模型 灰色预测模型是一种利用少量的、不完全的信息&#xff0c;建立数学模型并进行预测的方法。该方法通过对系统行为特征的发展变化规律进行估计预测&#xff0c;同时也可以对行为特征的异常情况发生的时刻进行估计计算&#xff0c;并研究特定…...

OFDM 系统在 AWGN 信道下对不同载波频率偏移 (CFO) 的 BER 灵敏度研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…...

go基础07-了解map实现原理并高效使用

对于C程序员出身的Gopher来说&#xff0c;map类型是和切片、interface一样能让他们感受到Go语言先进性的重要语法元素。map类型也是Go语言中最常用的数据类型之一。 go 中 map 怎么表现&#xff1f; 一些有关Go语言的中文教程或译本将map称为字典或哈希表&#xff0c;但在这里…...

SpringMVC进阶:常用注解、参数传递和请求响应以及页面跳转

目录 一、常用注解 1.1.RequestMapping 1.2.RequestParam 1.3.ModelAttribute 1.4.SessionAttributes 1.5.RequestBody 1.6.RequestHeader 1.7.PathVariable 1.8.CookieValue 二、参数传递 2.1.基础类型String 2.2.复杂类型 2.3.RequestParam 2.4.PathVariable 2…...

nacos - centos7.x环境单机与集群快速部署

参考官网:https://nacos.io/zh-cn/docs/what-is-nacos.html 官方集群部署手册:https://nacos.io/zh-cn/docs/cluster-mode-quick-start.html 【单机部署】 1.下载 & 解压到安装目录 下载:wget -c https://github.com/alibaba/nacos/releases/download/2.1.2/nacos-ser…...

文心一言初体验,和ChatGPT语言理解能力比较

文章目录 第一个考验&#xff0c;语义理解第二个考验&#xff0c;历史问题的回答推荐阅读 百度旗下AI大模型文心一言宣布向全社会全面开放,所有用户都可以体验这款AI大模型了。要比较这两个语言模型&#xff0c;我们先设计好题目。 第一个考验&#xff0c;语义理解 题目1&…...

浏览器进程,性能指标,性能优化

目录 浏览器进程&#xff1a;多进程 主进程&#xff1a;显示、交互&#xff0c;增删进程 UI进程&#xff1a;控制地址栏、书签、前进后退 存储进程&#xff1a;cookie&#xff0c;webstorage&#xff0c;indexDB 渲染进程&#xff1a;每个标签页或窗口都有一个独立的渲染进…...

Python基础set集合定义与函数

set集合 集合的特点&#xff1a; 1.集合是无序 2.集合是去重 定义一个空集合 name_set set() 定义一个非空集合 name_set {a, b, c} 关系测试&#xff1a; 交集&#xff0c;并集&#xff0c;差集&#xff0c;对称差集 1.交集&#xff1a;intersection() 或者 & …...

【大数据之Kafka】九、Kafka Broker之文件存储及高效读写数据

1 文件存储 1.1 文件存储机制 Topic是逻辑上的概念&#xff0c;而partition是物理上的概念&#xff0c;每个partition对应于一个log文件&#xff0c;该log文件中存储的是Producer生产的数据。 Producer生产的数据会被不断追加到该log文件末端&#xff0c;为防止log文件过大导致…...

Android 使用Camera2 API 和 GLSurfaceView实现相机预览

GLSurfaceView 和 SurfaceView 是 Android 中用于显示图像的两个视图类&#xff0c;它们在实现方式和使用场景上有一些区别。 实现方式&#xff1a;GLSurfaceView 基于 OpenGL ES 技术实现&#xff0c;可以通过 OpenGL ES 渲染图像。而 SurfaceView 则是通过基于线程的绘制方式…...

说说IO多路复用

分析&回答 IO多路复用 I/O multiplexing 这里面的 multiplexing 指的其实是在单个线程通过记录跟踪每一个Sock(I/O流)的状态(对应空管塔里面的Fight progress strip槽)来同时管理多个I/O流。直白点说&#xff1a;多路指的是多个socket连接&#xff0c;复用指的是复用一个…...

mysql 锁解决的办法

可以查看锁的信息,TRX_MYSQL_THREAD_ID 为processlist的表中的会话id,用于kill select trx_id,trx_state,trx_started,trx_requested_lock_id,trx_wait_started,trx_weight,trx_mysql_thread_id,trx_query from innodb_trx 可以查看锁的模式&#xff0c;类型&#xff0c;锁的表…...

哈尔滨最新/关键词优化如何

new Date(str)MM-dd-yyyy yyyy/MM/dd MM/dd/yyyy MMMM dd, yyyy MMM dd, yyyy dd MMM yyyydd MMMM yyyyMMM dd yyyyMMMM dd yyyy转载于:https://www.cnblogs.com/qinghao/archive/2010/01/18/1651145.html...

asp作业做购物网站代码/网页关键词排名优化

使用MMKV替代SharedPreferences&#xff0c;好处&#xff1a;MMKV是微信应用程序中使用的一种高效、小巧、易用的移动键值存储框架。目前在iOS、macOS、Android和Windows上都可以使用。一、在app的build.gradle中引入implementation com.tencent:mmkv:1.0.19二、在application里…...

哈尔滨做网站费用报价/百度云盘登录入口

1.11〓系统调用和库函数 所有操作系统都提供多种服务的入口点&#xff0c;由此程序向系统核请求服务。各种版本的Unix都 提供经良好定义的有限数目的入口点&#xff0c;经过这些入口点进入系统核&#xff0c;这些入口点被称之为 系统调用(system call)&#xff0c;系统调用是我…...

微信上如何做网站/鞍山seo优化

1、代码组成部分 app: manifests AndroidManifest.xmljava com.example.honl(androidTest)com.example.honl.muiscoco BaseActivity 抽象类&#xff0c;绑定/解绑ServicebottomInfoFr 点击“更多选项”中的“歌曲信息”弹出的片段cocoPlayerAPP ApplicationConstant 一些常量Lo…...

佛山市网站建设系统/seo关键词怎么填

较老版本的 AFNetworking 下载链接 http://pan.baidu.com/s/14Cxga 将压缩包中的文件夹拖入xcode工程项目中并引入如下的框架 简单的 JOSN 解析例子 static NSString *serverAddress "http://m.weather.com.cn/data/101110101.html"; // 1.创建JSON操作对象 A…...

贵阳个人做网站/网站建设平台官网

转自&#xff1a;https://blog.csdn.net/KYJL888/article/details/77846122 a) int a;表示一个内存空间&#xff0c;这个空间用来存放一个整数&#xff08;int&#xff09;&#xff1b; b) int* a;表示一个内存空间&#xff0c;这个空间用来存放一个指针&#xff0c;这个指针指…...