LCC '22 Contest 3 S1 - Geometric Square

View as PDF

Submit solution

Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

Bob's favorite pastime over the summer break is doing Sudoku puzzles. This summer, he has decided to expand his horizons to other puzzles since he has so much extra time on his hands. In particular, he has become interested in a new puzzle involving a 3 by 3 grid.

The objective of the game is to fill in all of the cells with positive integers such that each row, when read left to right, and each column, when read top to bottom, form geometric sequences. As a refresher, geometric sequences of length 3 have the following form (where a and r are positive real numbers).

\displaystyle 
a, ar, ar^2

Bob has already completed the puzzle. However, he would like you to write a program that checks that his solution is valid according to the rules.

Input Specification

There will be 3 lines of input each containing 3 space-separated integers, the values in the grid (1 \le a_{ij} \le 10^9).

Output Specification

Output GOOD if the grid is valid and BAF otherwise.

Sample Input 1

4 4 4
8 12 18
16 36 81

Sample Output 1

GOOD

Sample Input 2

1 2 3
4 5 6
7 8 9

Sample Output 2

BAF

Comments

There are no comments at the moment.