5480.Absolutely Flat

Time Limit: 1s Memory Limit: 256MB

Alice is a proud owner of a four-legged table, and she wants her table to be flat. Alice considers the table to be flat if its four legs have equal lengths.

Alice measured the table's current leg lengths and got $a_1, a_2, a_3$, and $a_4$. She also has a pad of length $b$. Alice can attach the pad to one of the legs, in which case the length of that leg will increase by $b$. She can also decide not to attach the pad, in which case the lengths of the legs will not change. Note that Alice has just a single pad, so she can neither apply it twice to the same leg nor apply it to two different legs.

Find out whether Alice can make her table flat.

Input Format(From the terminal/stdin)

The input contains five positive integers $a_1, a_2, a_3, a_4$, and $b$, each on a separate line--- the lengths of the table's legs, and the length of the pad Alice has ($1 \le a_i, b \le 100$).

Output Format(To the terminal/stdout)

Print $1$ if Alice can make her table flat, and $0$ otherwise.

Sample Input 1

Copy
10
10
10
10
5
  \n
  \n
  \n
  \n
 \n

Sample Output 1

Copy
1
 \n

Sample Input 2

Copy
13
13
5
13
8
  \n
  \n
 \n
  \n
 \n

Sample Output 2

Copy
1
 \n

Sample Input 3

Copy
50
42
42
50
8
  \n
  \n
  \n
  \n
 \n

Sample Output 3

Copy
0
 \n

Sample Input 4

Copy
20
40
10
30
2
  \n
  \n
  \n
  \n
 \n

Sample Output 4

Copy
0
 \n

Hints

In the first example test, the table is already flat, no pad is needed.

In the second example test, Alice can apply the pad to the third leg to make the table flat.

In the third and the fourth example tests, Alice can not make her table flat.

Source: NWRRC 2022

Submit

请先 登录

© 2025 FAQs