Comments

Let's look at an example. x = 1, y = 2^4 * 3^3 ^ 7^2 ( = 21168), k = 28. Then your algorithm will combine the prime factors into the following groups: [7, 3], [7, 3], [3, 2, 2, 2], [2]. It would be better though: [7, 2, 2], [7, 2, 2], [3, 3, 3]

I solved problem 2114F - Small Operations using simulated annealing, which is certainly not the best way, but it was interesting. My solution 321712725. I create arrays of prime factors to divide and multiply our number by, and then try to greedily divide them into groups with product less than k, starting from the beginning of the array.

2091G - Gleb and Boating I solved it in O(k^2 log k). Let's consider the number m (=k-2*j), let's get a dp of size m, where in the index i there will be a maximum or minimum position (depending on where we are going at the moment: left or right) that can be reached and which has a remainder i modulo M. Thus, we will iterate through all q from k to m and update dp, if at some point we have dp[s%m] ==s, then m suits us. Let's call this algorithm for m as check(m) -> true/false. If we consider all the numbers k, k-2, k-4, ..., and for them check(k), check(k-2), check(k-4), ... then false will go first, then true. We'll do a bin search for them and find the answer. If everything is false, we'll output 1.

My solution: 319579708

In the tutorial for problem E (Not a Nim Problem), the last paragraph says "if x is a composite prime number...", is this probably a typo? I think it would be correct to write "if x is an odd composite number..."

upd: I saw such a comment with such content, I apologize