コード例 #1
0
        protected override void Solve(out string answer)
        {
            int                   sum    = 0;
            PrimeSolver           solver = new PrimeSolver();
            List <Representation> list   = new List <Representation>();

            Parallelization.GetParallelRanges(1, 10_000_000, 100).ForAll(sequence =>
            {
                foreach (int number in sequence)
                {
                    var rep = new Representation(solver, number);
                    if (rep.IsPrime())
                    {
                        if (rep.IsTruncatable())
                        {
                            lock (this) list.Add(rep);
                        }
                    }
                }
            }
                                                                         );
            sum = list.Sum(el => el.Number);
            StringBuilder DEBUGString = new StringBuilder().AppendLine();

            list.ForEach(item => DEBUGString.Append($"{item}, "));
            answer = $"Computing... Sum = {sum}. List size = {list.Count}. {DEBUGString}";
        }