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 ...
随机推荐
- list排序,顺序,倒序
Collections.sort(list); // 顺序排列 Collections.reverse(list); // 倒序排列 Collections.shuffle(list); // 无序
- js 处理 cookie的存储与删除
<script> //JS操作cookies方法! //写cookies function setCookie(c_name, value, expiredays){ var exdate ...
- Alibaba Java Coding Guidelines
阿里巴巴于10月14日在杭州云栖大会上,正式发布众所期待的<阿里巴巴Java开发规约>扫描插件!该插件由阿里巴巴P3C项目组研发.P3C是世界知名的反潜机,专门对付水下潜水艇,寓意是扫描出 ...
- 稳定获取Android设备唯一码(UUID)的解决方案
最近做的一个项目中需要用到Android设备唯一码(UUID)来标识一台设备, Android中设备唯一码有很多,如:MAC地址.IMEI号(DeviceId).IMSI号.ANDROID_ID.序列 ...
- 2015-09-29 js2
Javasript 六. 条件语句 1. 比较运算符 == .!=.>.>=.<.<= 转大/小写:toUpperCase().toLowerCase() 2. 逻辑运算符(与 ...
- 【转】jquery.validate.js表单验证
一.用前必备官方网站:http://bassistance.de/jquery-plugins/jquery-plugin-validation/ API: http://jquery.bassist ...
- [LeetCode] 95. Unique Binary Search Trees II(给定一个数字n,返回所有二叉搜索树) ☆☆☆
Unique Binary Search Trees II leetcode java [LeetCode]Unique Binary Search Trees II 异构二叉查找树II Unique ...
- I/O复用(select)——回声服务器端/客户端
一.select 使用select函数可以将多个文件描述符集中到一起统一监视,监视事件如下: 是否存在待读取数据. 是否可传输无阻塞传输数据. 是否发生异常. 将关心上述3种事件的文件描述发分别注册到 ...
- LY.猜字小游戏
猜字小游戏
- xadmin自定义关联菜单
网上好多自定义xadmin后台数据很少有关怎样设置外键关联菜单的显示,如下图所示: 现有个需求根据model中status字段值,来显示关联菜单三道杠,如上图app状态只有是审核成功才会显示,未审核不 ...