luogu#P2067. Cytus-Holyknight

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.

Problem 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 kk and bb are constants):

  • y=kx+by=kx+b
  • y=kxy=kx
  • y=by=b
  • x=bx=b

Input Format

The first line contains a positive integer nn, indicating the size of the figure is n×nn\times n.

The next nn lines each contain nn 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.

3
010
111
x1x

y=-1.0000

Hint

The testdata guarantees a unique solution.

Constraints: For 100% of the testdata, 3n163\le n\le16.

Translated by ChatGPT 5