Editing
2015 Dec Bronze Problem 1 Fence Painting
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Problem == Farmer John is painting his fence. The fence is 1-dimensional, with positions along the fence denoted by integers. Two sections of the fence need to be painted, both described by two integers $a$ and $b$ ($a \le b$), and $c$ and $d$ ($c \le d$), indicating that the interval from $a$ to $b$ and from $c$ to $d$ need to be painted. It's possible that these intervals overlap. Your task is to compute the total length of the fence that needs to be painted. The input file, "paint.in", starts with two space-separated integers, $a$ and $b$ ($0 \le a < b \le 100$). The second line of the input contains another two space-separated integers, $c$ and $d$ ($0 \le c < d \le 100$). The output file, "paint.out", should output one line with one integer β the total length of the fence that needs to be painted.
Summary:
Please note that all contributions to Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
My wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information