PLOT1 - Plotting functions (variation)

Given a function y=f(x) in RPN-notation plot it with stars (*) and then (!) its derivation with crosses (+) for 0<=x<=20 with Δx=1 in a diagram with 21*21 points (0<=x,y<=20). Empty fields are marked with dots (.). For plotting the real number y should be rounded to integer (-0.5 -> -1, -0.4 -> 0, 0.4 -> 0, 0.5 -> 1). The function and its derivation are continuous between 0 and 20.
The function definition uses only the following characters: 0123456789x.+-*/^
'^' means 'power of'. Items are separated by space.

Input

In the first line the number N of functions, then N lines with one function.

Output

The plot of each function and its derivation in 21 lines.

Example

Input:
1
x 1 - Output: .....................
....................*
...................*.
..................*..
.................*...
................*....
...............*.....
..............*......
.............*.......
............*........
...........*.........
..........*..........
.........*...........
........*............
.......*.............
......*..............
.....*...............
....*................
...*.................
+++++++++++++++++++++
.*...................

Added by:HWK
Date:2011-03-02
Time limit:0.100s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64

hide comments
2023-11-11 13:20:31
can anyone give me the output from Divanshu: 2011-11-30 08:42:55\
2
x 1 -
x 2 ^
2012-09-17 15:18:17 (Tjandra Satria Gunawan)(曾毅昆)
The f(x) format is not like this:
variable/number variable/number operator
2012-09-17 13:47:04 numerix
Input data is okay and formatted as explained in the description.
2012-09-16 09:51:01 (Tjandra Satria Gunawan)(曾毅昆)
getting NZEC, I don't know the input formatting. Seems that it not like the example given above... :-(
2011-11-30 08:42:55 Divanshu
can anyone give some more test cases?
I'm getting right answer for :
2
x 1 -
x 2 ^
Still getting WA !
2011-10-03 14:55:57 Andrey Fedorov
@ HWK: Thank you very much:)
2011-10-03 12:16:17 HWK
@Andrey Fedorov: Make dx even smaller!
I've decreased it in your 5753568 and immediately got AC.

Last edit: 2011-10-03 12:20:54
2011-10-01 09:44:07 HWK
@Andrey Fedorov: Your problem are the derivations. Think about dx e.g. in your last solution. ;-)
2011-09-30 12:01:26 HWK
In:
1
x 2 ^
Out:
..........+..........
.....................
.........+...........
.....................
....*...+............
.....................
.......+.............
.....................
......+..............
.....................
.....+...............
...*.................
....+................
.....................
...+.................
.....................
..+..................
.....................
.+...................
.*...................
+....................

btw: Your 5750827 is really good. Only one mistake with a derivation.

Last edit: 2011-09-30 12:14:22
2011-09-30 07:31:50 Andrey Fedorov
Hi!
If I draw f(x) = x*x, do I need to fill points with y in {2,3,5,6,7...} ?
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.