import java.util.*; public class primal_font { public static void main(String[] args) { new primal_font(new Scanner(System.in)); } // Labels all prime divisors of some number n using a sieve. Each number // less than 1_000_000 has at most 7 prime divisors. // // Proof: 2*3*5*7*11*13*17*19 > 1_000_000 // The product of the smallest 8 primes is greater than 1 million. // The product of the smallest k integers in any subset of positive integers // is the smallest such value possible. ArrayList[] primeDivisors; int[] score; void genTable(int n) { primeDivisors = new ArrayList[n+1]; for (int i=0; i<=n; i++) primeDivisors[i] = new ArrayList(); for (int i=2; i<=n; i++) if (primeDivisors[i].size() == 0) for (int j=i; j<=n; j+=i) primeDivisors[j].add(i); score = new int[n+1]; for (int i=0; i<=n; i++) score[i] = primeDivisors[i].size() == 0 ? 0 : primeDivisors[i].get(primeDivisors[i].size()-1); } // Returns a representative that has all the same prime divisors of the // two given numbers. :) This number has the same prime divisors as the // GCD of the two numbers as well. int intersect(int a, int b) { ArrayList primes1 = primeDivisors[a], primes2 = primeDivisors[b]; int res = 1; int ptr1 = 0, ptr2 = 0; while (ptr1 < primes1.size() && ptr2 < primes2.size()) { int v1 = primes1.get(ptr1), v2 = primes2.get(ptr2); if (v1 < v2) ptr1++; else if (v1 > v2) ptr2++; else { res *= v1; ptr1++; ptr2++; } } return res; } // Find out if we can partition the array with at least minScore. boolean canPartition(int minScore) { // Save the representative in each value. int[] dp = new int[K], nxt = new int[K]; dp[0] = vs[0]; for (int i=0; i=0; k--) if (score[dp[k]] >= minScore) nxt[k+1] = vs[i]; for (int k=0; k= minScore; } int N, K; int[] vs; public primal_font(Scanner in) { genTable(1_000_000); int res = 0; for (int v=0; v