-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1154G.cpp
More file actions
41 lines (37 loc) · 712 Bytes
/
1154G.cpp
File metadata and controls
41 lines (37 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define ll long long
#define MAXN 10000010
using namespace std;
int n,x,y,id[MAXN],a[2];
ll k[2],ans=1e18;
void f(ll p,int a1,int a2)
{
if(ans>p) ans=p,a[0]=a1,a[1]=a2;
}
int main()
{
cin>>n;
FOR(i,1,n+1)
{
cin>>x;
if(id[x]) f(x,id[x],i);
id[x]=i;
}
FOR(i,1,MAXN-1)
{
y=0;
for(int j=i;j<MAXN;j+=i)
{
if(id[j]) k[y++]=j;
if(y==2)
{
f(1ll*k[0]*k[1]/i,id[k[0]],id[k[1]]);
break;
}
}
}
if(a[0]>a[1]) swap(a[0],a[1]);
cout<<a[0]<<' '<<a[1]<<'\n';
return 0;
}