Paint the Ceiling
Updated
Problem statement
Generate n allowed side lengths. Set s[0] = s0 and, for i > 0, set s[i] = s[i-1] + 1 + ((k * s[i-1] + b) mod m).
Count ordered pairs of indices (i,j) whose rectangle area s[i] * s[j] is at most area. Both orientations count separately when the indices differ, and using the same side twice is allowed. For example, sides [2,4,6] with area limit 15 allow (2,2), (2,4), (2,6), (4,2), (6,2), giving 5.
For this exercise, assume the bounds below and return a signed 64-bit count. Intermediate area products can exceed 64-bit range; compare them without overflow.
Function
paintTheCeiling(s0: int, n: int, k: int, b: int, m: int, area: long) → longExamples
Example 1
s0 = 2n = 3k = 3b = 3m = 2area = 15return = 5The recurrence gives 2, 4, 6; the five ordered pairs are listed in the statement.
Example 2
s0 = 3n = 1k = 0b = 0m = 1area = 9return = 1The only available side is 3; its square has area 9.
Example 3
s0 = 4n = 2k = 0b = 0m = 1area = 15return = 0The sides are 4 and 5, and even the smallest square has area 16.
Constraints
1 <= n <= 100000.1 <= s0, m <= 1000000.0 <= k, b <= 1000000.1 <= area <= 1000000000000000000.- The recurrence’s multiplication fits signed 64-bit under these limits, while side-area products need not.
More Roblox Online Assessment questions
- Centered Block Placement QueriesOA · Seen Oct 2026
- Robot Navigation Around LasersOA · Seen Oct 2026
- Factory Batch Profit (Game Adaptation)OA · Seen Sep 2026
- Nested Recipe Blocks (Game Adaptation)OA · Seen Sep 2026
- Vehicle Builds for Required Terrain (Game Adaptation)OA · Seen Sep 2026
- Track Received Byte RangesOA · Seen Sep 2026
- Break a PalindromeOA · Seen Jun 2026
- Count Pairs Differing in One DigitOA · Seen Oct 2025
- Find Zero Cells in a 2×2 GridOA · Seen Oct 2025
- Cat Route Budget Planning (Game Adaptation)OA · Seen Aug 2025
Similar questions at other companies
- Paint the CeilingWeRide · OAWeRide interview questions
- Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
- Find All Pythagorean TripletsDell Technologies · PHONE SCREENDell Technologies interview questions
- Sort a Quadratic-Transformed ArrayLinkedIn · PHONE SCREENLinkedIn interview questions
- Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
- Fill Missing Points on Line SegmentsDatadog · PHONE SCREENDatadog interview questions
- Count Centaur Friend RequestsMeta · PHONE SCREENMeta interview questions
- Minimum Rounds to Complete All TasksInfosys · OAInfosys interview questions
- Capping Portfolio WeightsCapstone Investment Advisors · OA
- Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions