HDU6098-Inversion
来源:互联网 发布:石材行业做效果图软件 编辑:程序博客网 时间:2024/05/17 21:41
Inversion
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 562 Accepted Submission(s): 378
Problem Description
Give an array A, the index starts from 1.
Now we want to know Bi=maxi∤jAj , i≥2.
Input
The first line of the input gives the number of test cases T; T test cases follow.
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
Output
For each test case output one line contains n-1 integers, separated by space, ith number is Bi+1.
Sample Input
2
4
1 2 3 4
4
1 4 2 3
Sample Output
3 4 3
2 4 4
Source
2017 Multi-University Training Contest - Team 6
题目大意:求
解题思路:用结构体保存数列a的值与坐标,按值从大到小排序,对每个
#include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>using namespace std;typedef long long LL;const int MAXN=1e5+5;struct node{ int v,id;}a[MAXN];bool cmp(node x,node y){ return x.v>y.v;}int main(){ int T; scanf("%d",&T); while(T--) { int n; scanf("%d",&n); for(int i=1;i<=n;++i) { scanf("%d",&a[i].v); a[i].id=i; } sort(a+1,a+n+1,cmp); bool flag=true; for(int i=2;i<=n;++i) { for(int j=1;j<=n;j++) { if(a[j].id%i!=0) { if(!flag) {printf(" %d",a[j].v);break;} else {printf("%d",a[j].v);flag=false;break;} } } } printf("\n"); } return 0;}
- HDU6098 Inversion
- HDU6098(Inversion)
- HDU6098-Inversion
- HDU6098 Inversion
- HDU6098-Inversion
- hdu6098--Inversion
- HDU6098 Inversion 签到
- Hdu6098 Inversion(2017多校第6场)
- HDU6098-2017多校6-贪心&水-Inversion
- 2017杭电多校联赛6-Inversion-排序-hdu6098
- hdu6098
- HDU6098 Inversion -2017多校联盟6 第3题
- hdu6098 Inversion 2017多校第六场1003 埃氏筛法
- HDU6098 Inversion(RMQ,2017 HDU多校联赛 第6场)
- inversion
- Inversion
- Inversion
- hdu6098思维+队列
- CSS3的【transition-duration】属性
- HDU 1863 畅通工程
- 基础:Linux 内核剖析
- 开发网络常识
- 梯度下降
- HDU6098-Inversion
- 【JZOJ 5250】【GDOI2018模拟8.11】质数
- 数字证书及其认证过程
- node并发控制
- 初识nodejs14
- 最陌生的老朋友Softmax Loss
- js BOM
- 热分析之路-MRF模拟轴流风机
- android控件之EditText