using System; using System.Linq; using System.Collections.Generic; namespace test20190423 { class Program { static void Main(string[] args) { DateTime baseDay = new DateTime(2015, 1, 1); Func cal = (s, n1, n2) => int.Parse(s.Substring(n1, n2)); List ss = new List(); for (int i = 0; i < 365; i++) { var s = (baseDay + new TimeSpan(i, 0, 0, 0)).ToString(); if (cal(s, 5, 2) == cal(s, 8, 1) + cal(s, 9, 1)) { ss.Add(s); //Console.WriteLine(s); } } Console.WriteLine(ss.Count); //Console.ReadLine(); } } }