HDU 6098 17多校6 Inversion(思维+优化)
Now we want to know Bi=maxi∤jAj , i≥2.
Each case begins with one line with one integer n : the size of array A.
Next one line contains n integers, separated by space, ith number is Ai.
Limits
T≤20
2≤n≤100000
1≤Ai≤1000000000
∑n≤700000
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<cstring> using namespace std;
int t,n;
struct node
{
long long k;
int pos;
}a[];
int b[];
bool cmp(node a,node b)
{
return a.k>b.k;
} int main()
{
scanf("%d",&t);
for(;t>;t--)
{
scanf("%d",&n);
for(int i=;i<=n;i++)
{
scanf("%lld",&a[i].k);
a[i].pos=i;
}
sort(a+,a++n,cmp);
memset(b,-,sizeof(b));
for(int j=;j<=n;j++)
{
if(a[].pos%j!=)
b[j]=a[].k;
}
for(int i=;i<=n;i++)
{
if(b[i]!=-)
continue;
for(int j=;j<=n;j++)
if (a[j].pos%i!=)
{
b[i]=a[j].k;
break;
}
}
printf("%d",b[]);
for(int j=;j<=n;j++)
printf(" %d",b[j]);
printf("\n");
}
return ;
}
HDU 6098 17多校6 Inversion(思维+优化)的更多相关文章
- HDU 6140 17多校8 Hybrid Crystals(思维题)
题目传送: Hybrid Crystals Problem Description > Kyber crystals, also called the living crystal or sim ...
- HDU 6124 17多校7 Euler theorem(简单思维题)
Problem Description HazelFan is given two positive integers a,b, and he wants to calculate amodb. Bu ...
- HDU 3130 17多校7 Kolakoski(思维简单)
Problem Description This is Kolakosiki sequence: 1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1……. This seq ...
- HDU 6034 17多校1 Balala Power!(思维 排序)
Problem Description Talented Mr.Tang has n strings consisting of only lower case characters. He want ...
- HDU 6092 17多校5 Rikka with Subset(dp+思维)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- HDU 6090 17多校5 Rikka with Graph(思维简单题)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- HDU 6095 17多校5 Rikka with Competition(思维简单题)
Problem Description As we know, Rikka is poor at math. Yuta is worrying about this situation, so he ...
- HDU 6049 17多校2 Sdjpx Is Happy(思维题difficult)
Problem Description Sdjpx is a powful man,he controls a big country.There are n soldiers numbered 1~ ...
- HDU 6143 17多校8 Killer Names(组合数学)
题目传送:Killer Names Problem Description > Galen Marek, codenamed Starkiller, was a male Human appre ...
随机推荐
- DOM与document的区别
DOM: DOM 全称是 Document Object Model,也就是文档对象模型. DOM 就是针对 HTML 和 XML 提供的一个API.什么意思?就是说为了能以编程的方法操作这个 HTM ...
- java 静态代理和动态代理
代理模式 一.概述 代理是一种模式,提供了对目标对象的间接访问方式,即通过代理访问目标对象.如此便于在目标实现的基础上增加额外的功能操作,前拦截,后拦截等,以满足自身的业务需求,同时代理模式便于扩展目 ...
- python-day73--django-分页
''' 批量导入数据:bulk_create Booklist=[] for i in range(100): Booklist.append(Book(title="book"+ ...
- Wannafly挑战赛27-A/B
链接:https://www.nowcoder.com/acm/contest/215/A来源:牛客网 题目描述 “White shores, and beyond. A far green coun ...
- 数据结构与算法之PHP查找算法(顺序查找)
对于查找数据来说,最简单的方法就是从列表的第一个元素开始对列表元素逐个进行判断,直到找到了想要的结果,或者直到列表结尾也没有找到,这种方法称为顺序查找. 一.基本写法 顺序查找的实现很简单.只要从列表 ...
- C# 3.0 / C# 3.5 系统内置委托
内置委托的定义声明: System.Func,代表有返回类型的委托: public delegate TResult Func<out TResult>(); public delegat ...
- Oracle date timestamp 毫秒 - 时间函数总结(转)
原文地址:Oracle date timestamp 毫秒 - 时间函数总结 yyyy-mm-dd hh24:mi:ss.ff 年-月-日 时:分:秒.毫秒 --上一月,上一年select add_ ...
- MySQL_插入更新 ON DUPLICATE KEY UPDATE
平时我们在设计数据库表的时候总会设计 unique 或者 给表加上 primary key 的限制条件. 此时 插入数据的时候 ,经常会有这样的情况: 我们想向数据库插入一条记录: 若数据表中存在以 ...
- python爬虫基本原理及入门
爬虫:请求目标网站并获得数据的程序 爬虫的基本步骤: 使用python自带的urllib库请求百度: import urllib.request response = urllib.request.u ...
- 反向代理/负载均衡/session/cookie
正向代理:客户端将流量重定向到burpsuite等软件或连接到VPN再访问服务器而不是直接访问服务器的场景.流量流动方向是真正机器--代理服务器.正向代理又称代理.普通代理. 反向代理:服务器端使用反 ...