using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { public void Proc() { Reader.IsDebug = false; int itemCount = int.Parse(Reader.ReadLine()); this.NumList = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).OrderBy(a=>a).ToArray(); int ans = 1; for(int i=0; i dic = new Dictionary(); private int GetAns(int idx) { if(dic.ContainsKey(idx)) { return dic[idx]; } int ans = 1; for(int i=idx+1; i NumList[idx] && NumList[i] % NumList[idx] == 0) { int ret = this.GetAns(i); ans = Math.Max(ans, ret + 1); } } dic.Add(idx, ans); return ans; } public class Reader { public static bool IsDebug = true; private static String PlainInput = @" 7 3 4 8 9 16 27 432 "; private static System.IO.StringReader Sr = null; public static string ReadLine() { if (IsDebug) { if (Sr == null) { Sr = new System.IO.StringReader(PlainInput.Trim()); } return Sr.ReadLine(); } else { return Console.ReadLine(); } } } static void Main() { Program prg = new Program(); prg.Proc(); } }