using System; using System.Collections.Generic; using System.Text; namespace Csharp { class Program { static HashSet<string> Set = new HashSet<string>(); static StringBuilder SB = new StringBuilder(); static void Main(string[] args) { int N = Convert.ToInt32(Console.ReadLine()); for (int i = 0; i < N; ++i) { string word = Console.ReadLine(); if (false == Check(word)) Set.Add(word); } Console.WriteLine(Set.Count); } static bool Check(string word) { SB.Clear(); SB.Append(word); foreach (string src in Set) { for (int i = 0; i < word.Length; ++i) { if (src == SB.ToString()) return true; SB.Append(SB[0]).Remove(0, 1); } } return false; } } } |