Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This program should run in o(logn) time, no external libraries allowed, languages Python, Java or C++ CC A certain video game features lightning bugs that
This program should run in o(logn) time, no external libraries allowed, languages Python, Java or C++
CC A certain video game features lightning bugs that instantaneously teleport from point to point on the screen, generally causing mayhem. They stand still for only a short while before they "apparate' to another point on the screen. The player is supposed to zap the bug while it is standing still. The skill in the game comes from anticipating where the bug will appear next, because it actually moves deterministically, although the pattern it follows may not be obvious to the uninitiated. Su ME Di Ra A game instance is initialised with two integer parameters, a and b that remain constant for the duration of that game. A single "micro-update of a bug's position causes its coordinates to evolve according to the rule: (x,y) (a - by, ay+bat) M: The update from when a bug disappears to wherever it reappears is called a step. A single 'step' of the bug usually involves several micro-updates. The game progresses in levels of difficulty, the higher the level, the more micro-updates that the bug takes on a single step. Initially, at level o, a single step contains only 1 micro- update. With each new level though, the number of micro-updates comprising a step increases by a constant C. A bug moves with the same step size until it is zapped by the player, at which point the level of the game increases by 1, and the next bug appears at the position obtained by taking a single step of the new size from the position of the zapped bug. The screen has square dimensions of lengths (an integer) and the legal coordinates range from (0,0) to (8-1, 1) inclusive. If the calculated coordinates of a bug should be outside of the legal screen coordinates, they are interpreted to "wrap around the screen. So, the right side of the screen is imagined to be connected to the left side of the screen, in much the same way that in a map of the world, the points at the rightmost edge of the map are actually neighbours to those at the leftmost points. This 'Wrapping' occurs in the vertical direction also. So, for example, if a = 12 then the legal range of coordinates is from (0,0) to (11, 11), and the coordinates (20, 12) would be interpreted as the point (8,0). For a given level, I, and initial position (109) at levell, if a bug made a steps before being zapped, determine its final position Input Format Two lines, each containing 4 space separated integers: abc S XO yon Constraints la 10 15Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started