I think I need a houseboat

Fred is hoping to live in his house the rest of his life, he needs to know if his land is going to be lost to erosion.

Problem “I think I need a houseboat” located at Peking University.

Solution

""" solution.py """

# usage: python3 solution.py < input

# "I think I need a houseboat" problem

import sys
import math


def point_inside(x, y):
    """ how many cycles before x, y is in the semi-circle """
    cycle, erosion = 0, 0.0
    distance, radius = 0.0, -1.0

    while distance > radius:
        cycle += 1
        erosion += 50.0
        radius = math.sqrt((erosion * 2.0) / math.pi)
        distance = math.sqrt(x * x + y * y)

    return cycle


with sys.stdin as infile:
    n = int(infile.readline())

    for i in range(n):
        px, py = map(float, infile.readline().split())
        year = point_inside(px, py)
        msg = f'This property will begin eroding in year {year}.'
        print(f'Property {i + 1}: ' + msg)

print('END OF OUTPUT.')

Output

Property 1: This property will begin eroding in year 1.
Property 2: This property will begin eroding in year 20.
END OF OUTPUT.