P2067 Cytus-Holyknight
Background
Originally created by me.
To commemorate the great music game Cytus on iOS, Android, and PSV.
Will be continuously updated.
------------- Chapter V-1 -------------
The two warriors were bored leaning together all day, so they decided to play a game!
They drew a cross with their swords and started tossing pebbles—so fun!
Each of them had one pebble. After they threw them, Xiao Lan (pinyin), who was self-studying math, shouted: If you connect them, isn’t that a linear function!
So, they connected them and began to calculate. Then they discovered a serious problem—no scratch paper!
With such weak imagination, they had to ask you for help.
Description
Given, in image form, several points on a straight line (all are integer points and none lie on the coordinate axes), output the equation of the line in one of the following forms (where $k$ and $b$ are constants):
- $y=kx+b$
- $y=kx$
- $y=b$
- $x=b$
Input Format
The first line contains a positive integer $n$, indicating the size of the figure is $n\times n$.
The next $n$ lines each contain $n$ characters. Character '1' marks the coordinate axes, 'x' indicates that the integer point lies on the line, and '0' indicates that the integer point does not lie on the line.
The horizontal row of '1's is the x-axis, and the vertical column of '1's is the y-axis.
The distances between adjacent rows and adjacent columns are always 1.
Output Format
Output one line: the equation of the line.
Constants should always be printed with 4 decimal places.
Explanation/Hint
The testdata guarantees a unique solution.
Constraints: For 100% of the testdata, $3\le n\le16$.
Translated by ChatGPT 5