hdu 多校联赛 Inversion
来源:互联网 发布:js 触发div事件 编辑:程序博客网 时间:2024/05/29 19:46
Inversion
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
Give an array A, the index starts from 1.
Now we want to knowBi=maxi∤jAj , i≥2 .
Now we want to know
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 isAi .
Limits
T≤20
2≤n≤100000
1≤Ai≤1000000000
∑n≤700000
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
Limits
Output
For each test case output one line contains n-1 integers, separated by space, ith number is Bi+1 .
Sample Input
241 2 3 441 4 2 3
Sample Output
3 4 32 4 4
ac代码:
#include<cstdio>#include<iostream>#include<cstring>#include<stdlib.h>using namespace std;const int N=1e5+10;struct Node{ int val; int pos;}A[N];int cmpDec(const void *a,const void *b)//怕超时特地用了快排 其实sort也能过{ return (((Node*)b)->val)-(((Node*)a)->val);}int main(){ int t; cin>>t; int n; while(t--) { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&A[i].val); A[i].pos=i; } qsort(A+1,N,sizeof(Node),cmpDec); for(int i=2;i<=n;i++) { for(int j=1;j<=n;j++) { if(A[j].pos%i!=0) { if(i==2) { printf("%d",A[j].val); break; } else { printf(" %d",A[j].val); break; } } } } printf("\n"); } return 0;}
阅读全文
0 0
- hdu 多校联赛 Inversion
- HDU6098 Inversion(RMQ,2017 HDU多校联赛 第6场)
- hdu 多校联赛 TrickGCD
- hdu 多校联赛 Questionnaire
- hdu 多校联赛 Classes
- 2015 HDU 多校联赛 5326 Work
- 2016多校联赛 hdu 5724 Chess
- 2016多校联赛 hdu 5728 PowMod
- HDU 5774 多校联赛第四场
- hdu 5823 2016多校联赛8
- hdu多校联赛 Balala Power!
- hdu 多校联赛 Regular polygon
- HDU 2017多校联赛-Regular polygon
- hdu 多校联赛 Maximum Sequence
- HDU 2017多校联赛-Maximum Sequence
- hdu 多校联赛 Is Derek lying?
- hdu 多校联赛 Add More Zero
- hdu 多校联赛 Colorful Tree
- js文件中如何使用EL表达式
- Csharp Json解析
- Hyperledger Fabric 之 环境搭建
- Eclipse 一直不停 building workspace... 完美解决总结
- CentOS6/7 使用saltstack源安装saltstack
- hdu 多校联赛 Inversion
- Ubuntu 16.04 LTS 下安装 ibus-rime 输入法
- PreferenceActivity之 Subclasses of PreferenceActivity must override isValidFragment(String)
- python中的np.random.normal
- centos7 修改时区
- LeetCode
- 关于shiro不进入successURL的问题
- python下setuptools安装( No module named setuptools 解决方案)
- 跳棋