Codey and Spam
https://www.hackerrank.com/contests/codenection-2024-preliminary-round-closed-category/challenges/cn24-3
Question
Codey is too excited for CodeNection 2024! It wanted to spam a series of lines arranged in a triangle on the Discord server. The height (vertex) of the triangle is n
, and it contains 2n-1
lines.
Example of n = 3
containing 5
lines:
However, Zoey will kick Codey out immediately if it spam at least x
CODENECTION
word consecutively. How many lines can Codey spam before Zoey kicks it out of the server?
Input Format
The first line contains two integers, n
and x
, where n
represents the height of the triangle and x
represents the maximum number of consecutive CODENECTION
allowed before Zoey kicks Codey out.
Constraints
Output Format
Output an integer representing the maximum number of lines Codey can spam before getting kicked out.
Sample Inputs:
Last updated