Mark loves to move fast. So he made a spaceship that works in 4-dimensional space. He wants to use the spaceship to complete missions as fast as possible. In each mission, the spaceship starts at (0, 0, 0, 0) and needs to end up at (a, b, c, d). To do this, he instructs the spaceship's computer to execute a series of moves, where each move is a unit step in one of the eight cardinal directions: (+1, 0, 0, 0), (0, 1, 0, 0), (0, 0, 1,0), (0, 0, 0, +1). Unfortunately, he also moved fast when building the spaceship, so there is a bug in the spaceship's code. The first move will be executed once, the second move will be executed twice, the third move will be executed thrice, and so on. In general, the i-th move will be executed ¿ times. For any four integers a, b, c, d, let f(a, b, c, d) be the minimum number of moves of a mission that ends up at (a, b, c, d). Compute the sum of f(a, b, c, d) over all points (with integer coordinates) such that -A < a < A-B < b

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter2: Elements Of High-quality Programs
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
Mark loves to move fast. So he made a spaceship that works in 4-dimensional space.
He wants to use the spaceship to complete missions as fast as possible. In each mission, the spaceship starts at (0, 0, 0, 0) and needs to
end up at (a, b, c, d). To do this, he instructs the spaceship's computer to execute a series of moves, where each move is a unit step in
one of the eight cardinal directions: (+1,0,0,0). (0,1,0,0), (0, 0, 1,0), (0, 0, 0, 1).
Unfortunately, he also moved fast when building the spaceship, so there is a bug in the spaceship's code. The first move will be executed
once, the second move will be executed twice, the third move will be executed thrice, and so on. In general, the i-th move will be executed
¿ times.
For any four integers a, b, c, d, let f(a, b, c, d) be the minimum number of moves of a mission that ends up at (a, b, c, d). Compute the
sum of f(a, b, c, d) over all points (with integer coordinates) such that A < a < A-B<b<B₁-C<c<C, D< d < D.
Input
The only line of the input contains the four integers A, B, C, D (0 < A, B, C, D < 1000).
Output
Print the sum of f(a, b, c, d) over the set of points described in the statement.
Examples
input
1000
output
2
input
110 1
output
82
input
3241
output
4616
Copy
Copy
Copy
Copy
Copy
Copy
Transcribed Image Text:Mark loves to move fast. So he made a spaceship that works in 4-dimensional space. He wants to use the spaceship to complete missions as fast as possible. In each mission, the spaceship starts at (0, 0, 0, 0) and needs to end up at (a, b, c, d). To do this, he instructs the spaceship's computer to execute a series of moves, where each move is a unit step in one of the eight cardinal directions: (+1,0,0,0). (0,1,0,0), (0, 0, 1,0), (0, 0, 0, 1). Unfortunately, he also moved fast when building the spaceship, so there is a bug in the spaceship's code. The first move will be executed once, the second move will be executed twice, the third move will be executed thrice, and so on. In general, the i-th move will be executed ¿ times. For any four integers a, b, c, d, let f(a, b, c, d) be the minimum number of moves of a mission that ends up at (a, b, c, d). Compute the sum of f(a, b, c, d) over all points (with integer coordinates) such that A < a < A-B<b<B₁-C<c<C, D< d < D. Input The only line of the input contains the four integers A, B, C, D (0 < A, B, C, D < 1000). Output Print the sum of f(a, b, c, d) over the set of points described in the statement. Examples input 1000 output 2 input 110 1 output 82 input 3241 output 4616 Copy Copy Copy Copy Copy Copy
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Processes of 3D Graphics
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr