using System; using System.IO; using System.Text; namespace Csharp { class Program { static int N = 0; static int[] Arr = new int[80]; static void Main(string[] args) { N = Convert.ToInt32(Console.ReadLine()); dfs(0); } static void dfs(int index) { if (index == N) { for (int i = 0; i < N; i++) Console.Write(Arr[i]); Environment.Exit(0); } for (int i = 1; i <= 3; i++) { Arr[index] = i; if (IsPromising(index)) dfs(index + 1); } Arr[index] = 0; } static bool IsPromising(int index) { for (int i = 1; i <= Math.Min((index + 1) / 2, N / 2); i++) { int right = index - (i - 1); int left = right - i; bool isBadPermutation = true; for (int j = 0; j < i; j++) { if (Arr[left + j] != Arr[right + j]) { isBadPermutation = false; break; } } if (isBadPermutation) return false; } return true; } } } |