public static void Run(Input input, Output output) { var pu = new PrimesUtils(2000000); var meta = input.ReadLine().Split(' '); var N = Int32.Parse(meta[0]); var K = Int32.Parse(meta[1]); int i = 2; while (i <= N) { var dividors = pu.GetPrimeDividors(i); var cnt = 0; var first = i; while (dividors.Count == K && cnt < K) { cnt++; i++; dividors = pu.GetPrimeDividors(i); } if (cnt >= K) { output.WriteLine(first.ToString()); i = i - K + 1; } else { i++; } } }
public void PrimesUtilsShouldCalculatePrimeDividors() { #region Arrange var n = 1008; var pu = new PrimesUtils(10000); #endregion #region Act var primeDividors = pu.GetPrimeDividors(n); #endregion #region Assert Assert.AreEqual(3, primeDividors.Count); Assert.AreEqual(4, primeDividors[2]); Assert.AreEqual(2, primeDividors[3]); Assert.AreEqual(1, primeDividors[7]); #endregion }