P8924 "GMOI R1-T1" Perfect Math Class

Description

Index gives you a function as follows: $$f(x)=a_kx^k+a_{k-1}x^{k-1}+\cdots+a_1x^1+a_0$$ Draw its graph (where `*` means the graph passes through that point, and `.` means it does not) on a grid of size $n \times m$, where the range of $x$ is $[0,n-1]$ and the range of $f(x)$ is $[0,m-1]$. Specifically, you need to output an $n \times m$ character matrix. If the function passes through an integer point $(x,y)$, then output `*` at the position that is the $(x+1)$-th column from left to right and the $(y+1)$-th row from bottom to top; otherwise output `.`.

Input Format

The first line contains three integers $n,m,k$. The second line contains $k+1$ integers, where the $i$-th integer represents $a_{i-1}$.

Output Format

Output a total of $m$ lines, each containing $n$ characters, which is the graph of the function. Specifically, output `*` at the position that is the $(x+1)$-th column from left to right and the $(y+1)$-th row from bottom to top if and only if the function passes through $(x,y)$; otherwise output `.`.

Explanation/Hint

Explanation for Sample $1$: The function is $f(x)=x$. Obviously, when $x\in[0,4], f(x)\in[0,4]$, it passes through the integer points $(0,0),(1,1),(2,2),(3,3),(4,4)$. For $100\%$ of the testdata, $-12\le a_i\le 12 $ and $n=m$. Each test point is equally weighted. | Test Point | $n\le$ | $m\le$ | $k\le$ | Special Property | | :----------: | :----------: | :----------: | :----------: | :----------: | | $1$ | $1$ | $1$ | $0$ | $-$ | | $2$ | $5$ | $5$ | $0$ | $-$ | | $3$ | $5$ | $5$ | $1$ | $a_1=1$ | | $4$ | $5$ | $5$ | $1$ | $a_0+a_1\le 2$ | | $5$ | $10$ | $10$ | $1$ | $-$ | | $6$ | $10$ | $10$ | $2$ | $a_0=a_1=0,a_2\ge n$ | | $7$ | $100$ | $100$ | $2$ | $-$ | | $8$ | $100$ | $100$ | $3$ | $-$ | | $9$ | $100$ | $100$ | $5$ | $-$ | | $10$ | $100$ | $100$ | $7$ | $-$ | Translated by ChatGPT 5