Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Geometry Forever

By TarifEzaz · Limits 1s, 512 MB

Fear no more, this is a problem of geometry!

When Moyna was little, he had a math teacher named Shukdeb. Shukdeb used to take math lessons everyday from Saturday to Thursday. But Thursday was special, it was the day when geometry lessons were given by him. For some mysterious reason, Shukdeb used to be very angry on Thursdays. On that day, when the students saw him coming, they immediately got stunned into silence. Shukdeb often used to call upon students, and asked them to prove a theorem on the blackboard. Failing to do so, would have resulted in serious punishments. This led to many students of the class, including Moyna, to fear geometry.

In one of these classes, Shukdeb had taught the students the following theorem:

“The sum of the lengths of any two sides of a triangle is greater than the length of the third side.”

Moyna found this theorem very interesting and wondered to himself, “If two sides of a triangle are given, how many possible values could the third side have, so that the resulting sides constructs a valid triangle?”

Moyna shared this problem with his friends, and you, as one of his better friends, can’t wait to solve it.


The only line of input contains two integer numbers A and B (1 ≤ A, B ≤ 100), the two sides of a triangle.


For each input, print one line of output, the total number of possible integer values the third side can take.


1 1



80% Solution Ratio

aminulEarliest, Mar '17

fsshakkhorFastest, 0.0s

wasimur_01Lightest, 0 B

fahmid07Shortest, 40B


Login to submit