Weirdwood's Age (WAGE) Editorial

A Weirwood’s Age - EDITORIAL

PROBLEM LINK:

Practice
Contest

Author: Hetal Kuvadia
Tester: Sana Pagarkar
Editorialist: Dhruvi Vadalia

DIFFICULTY:

Easy

PREREQUISITES:

Maths

PROBLEM:

You’re given 3 integers a, b, X.

  • a = radius of the first ring,
  • b = radius of the last ring,
  • X = distance between 2 rings.

You have to find the age of the tree by counting the number of rings.

EXPLANATION:

  • We can solve this problem very easily. First, take the 3 integers as input and check their constraints.
  • Then, we find the difference between the first and last rings’ radii, (b-a). We are given the distance between each ring, X.
  • We divide the difference calculated between the two radii by the distance to find the number of rings.
  • If the result is a floating point number, round it off with the floor value, because we need the answer in years.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author Solution can be found here
Tester Solution can be found here

4 Likes