Hey there, im back.
this time im with my OEIS solution! the DIV 4 contest had a question known as the 67th OEIS problem, at first i thought why not the $$$2^n$$$ thingy. as powers of two have diffrent unique gcds, then , i saw the constraints and cried for half an hour :[.
then i tried odds, and evens, then primes... PRIMES! but it disappointed me, well you see, primes will always have a gcd of 1 (theyre primes for a reason), but i wanted uniques, what do i do?? what if i square primes?? well, same result.. hm
the time that it actually hit me was when i did a mistake in my primes square calculating loop, missing my index by 1 indice and multiplying the next prime to my curProd (goofy var name). That was the best, it really gave unique gcds, so i wrote another code, with this logic. it worked.. YESS! thats how i got the answer, pretty dramatic, now heres the logic example:
eg: - $$$P_2 = 2 \cdot 3 = 6$$$ - $$$P_3 = 2 \cdot 3 \cdot 5 = 30$$$ - $$$P_4 = 2 \cdot 3 \cdot 5 \cdot 7 = 210$$$
gcd: - $$$\gcd(P_2, P_3) = \gcd(6, 30) = 6 = P_2$$$
- $$$\gcd(P_3, P_4) = \gcd(30, 210) = 30 = P_3$$$
Its Unique!
heres the code for those who want to absolutely destroy me in the face.
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
bool is_prime(int n) {
if(n<2) return false;
for (int i = 2; i*i <= n; i++)
if(n%i == 0) return false;
return true;
}
int main() {
fastio;
vector<int> primes;
for (int i = 2; primes.size() <= 10001; i++)
if(is_prime(i))
primes.push_back(i);
int t;
cin >> t;
while (t--) {
int n; cin >> n;
for (int i = 0; i < n; i++)
cout << primes[i] * primes[i+1] << " \n";
}
return 0;
}
for those who want a detailed explanation, go to the editorial's comments, i have my explanation written there.
OVER AND OUT




