Advertisement
Guest User

Untitled

a guest
May 3rd, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. class AB:
  2.     def createString(self, N, K):
  3.         if K == 0:
  4.             return 'A'*N
  5.         b = int(K**0.5)
  6.         y = K % b
  7.         q = K / b
  8.         x = q - y
  9.         if y > 0:
  10.             res = 'A'*y + 'B' + 'A'*x + 'B'*b
  11.         else:
  12.             res = 'A'*x + 'B'*b
  13.         if len(res) > N:
  14.             return ''
  15.         return res + 'A'*(N - len(res))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement