Submission #21248311


Source Code Expand

#include <atcoder/all>
using namespace atcoder;
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = 3.14159265359;
const ll INF = 1LL << 60;

ll p[15] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};

ll gety(int bm){
  ll r = 1;
  for (int i = 0; i < 15; i++){
    if (bm&1){
      r *= p[i];
    }
    bm >>= 1;
  }
  return r;
}

long long gcd(long long a, long long b)
{
  long long x = abs(a);
  long long y = abs(b);
  while (y > 0){
    long long r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main()
{
  int n;
  cin >> n;

  vector<ll> x(n);
  for (ll& t : x) cin >> t;

  ll ans = INF;
  for (int bm = 0; bm < (1 << 15); bm++){
    ll y = gety(bm);
    bool ok = true;
    for (ll xi : x){
      if (gcd(xi, y) == 1){
	ok = false;
	break;
      }
    }
    if (ok){
      ans = min(ans, y);
    }
  }

  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task A - Not coprime
User unnohideyuki
Language C++ (GCC 9.2.1)
Score 300
Code Size 962 Byte
Status AC
Exec Time 23 ms
Memory 3652 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 16
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt AC 11 ms 3508 KiB
02.txt AC 13 ms 3524 KiB
03.txt AC 23 ms 3628 KiB
04.txt AC 19 ms 3456 KiB
05.txt AC 10 ms 3456 KiB
06.txt AC 11 ms 3584 KiB
07.txt AC 16 ms 3484 KiB
08.txt AC 12 ms 3448 KiB
09.txt AC 15 ms 3448 KiB
10.txt AC 16 ms 3484 KiB
11.txt AC 14 ms 3584 KiB
12.txt AC 9 ms 3516 KiB
13.txt AC 12 ms 3624 KiB
s1.txt AC 8 ms 3652 KiB
s2.txt AC 11 ms 3628 KiB
s3.txt AC 12 ms 3624 KiB