BEAUTY SQUARE ;)

Math is fun, they said.

Two months ago, Mr. Oski was teaching his student about square number. Square number is a multiplication product of a number with the number itself. For example: 1 (1x1), 4 (2x2), 9 (3x3), ...
One day when he wrote down sequences of square number, he found something fun. What is the digit of the X position, and what is that square number. INPUT :The first line contains an integer denotes the number of cases. Each case contains an integer

IN

10
1
2
3
4
5
6
7
8
9
20

OUT

1 1
4 4
9 9
1 16
6 16
2 25
5 25
3 36
6 36
2 121

IN

3
8
9
20

OUT

3 36
6 36
2 121

IN

3
1
2
3

OUT

1 1
4 4
9 9

IN

6
1
2
3
4
5
6

OUT

1 1
4 4
9 9
1 16
6 16
2 25

IN

4
1
2
3
4

OUT

1 1
4 4
9 9
1 16
Login to submit solution


203 symbols perl failed test 1 Code error

syntax error at ./code line 1, near "(:" Substitution replacement not terminated at ./code line 2.

Tue Sep 18 06:26:49 2018 YoshikuniJujo
main=interact$unlines.map(uncurry(:).g.read).tail.lines
g n=(s!!(n-m),' ':s)where((m,_),s)=last.takeWhile((n>=).fst.fst).scanl(\((_,a),_)(b,c)->((a,a+b),c))((0,1),"")$(\s->(length s,s)).show.(^2)<$>[1..]
203 symbols haskell failed test 1 Code error

code:2:140: Not in scope: ‘<$>’

Tue Sep 18 06:27:15 2018 YoshikuniJujo
main=interact$unlines.map(uncurry(:).g.read).tail.lines
g n=(s!!(n-m),' ':s)where((m,_),s)=last.takeWhile((n>=).fst.fst).scanl(\((_,a),_)(b,c)->((a,a+b),c))((0,1),"")$(\s->(length s,s)).show.(^2)<$>[1..]
205 symbols haskell failed test 1 Code error

code:2:36: Precedence parsing error cannot mix ‘.’ [infixr 9] and ‘map’ [infixl 9] in the same infix expression

Tue Sep 18 06:28:34 2018 YoshikuniJujo
main=interact$unlines.map(uncurry(:).g.read).tail.lines
g n=(s!!(n-m),' ':s)where((m,_),s)=last.takeWhile((n>=).fst.fst).scanl(\((_,a),_)(b,c)->((a,a+b),c))((0,1),"")$(\s->(length s,s)).show.(^2)`map`[1..]

View all solutions