# coding: utf-8 N = input("文字数入力 >>> ") while int(N) < 1 or int(N) > 50000: N = input("文字数は1以上50000以下にしてください。文字数を再入力 >>> ") print("文字数:", N) D = input("穴数を入力 >>> ") while int(D) < 0 or int(D) > 2*int(N): D = input("穴数は0以上2×文字数以下にしてください。穴数を再入力 >>> ") print("穴数:", D) N = int(N) #文字数 D = int(D) #穴数 alfabetArr = ["A","B","C"] def generateAns(N, D): if N < D: numB = D - N numA = N - numB numC = 0 elif N == D: numA = N numB = 0 numC = 0 else: numA = N - D numC = N - numA numB = 0 answer = "" for i in range(numA): answer += str(alfabetArr[0]) for j in range(numB): answer += str(alfabetArr[1]) for k in range(numC): answer += str(alfabetArr[2]) return answer print(generateAns(N, D))