Skip to content

Instantly share code, notes, and snippets.

@modos
Created July 16, 2022 01:36
Show Gist options
  • Save modos/1dba823d461d77f08d74bde021b12c08 to your computer and use it in GitHub Desktop.
Save modos/1dba823d461d77f08d74bde021b12c08 to your computer and use it in GitHub Desktop.
ب.م.م.م
// ITNOA
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 13;
bool seen[N];
int a[N];
int main()
{
int n;
cin >> n;
for (int i = 0; i < n;i++)
scanf("%d", a + i);
int ans = 1;
seen[1] = 1;
for (int i = 0;i < n;i++)
{
int j = 1;
for (;j*j < a[i];j++)
{
if (a[i] % j == 0)
{
if (seen[j])
ans = max(ans, j);
if (seen[a[i] / j])
ans = max(ans, a[i] / j);
seen[j] = seen[a[i] / j] = true;
}
}
if (j*j == a[i])
{
if (seen[j])
ans = max(ans, j);
seen[j] = true;
}
}
cout << ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment