GUANGGUN - 111…1 Squared


We call an integer Sticks if its decimal representation contains only digit 1.

Let S(n) be the sticks with n digits, find the sum of digits of S(n)2

For example, S(9)2=12345678987654321, its sum of digits is 81.

Input

Each line contains an integer represents n(1 ≤ n ≤ 1018).

Input is terminated by EOF, and contains at most 100 lines.

Output

For each n, print an integer represents the answer.

Example

Input:
9
10

Output:
81
82

hide comments
shivansh19: 2019-11-14 18:53:55

1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
1234567900987654321
123456790120987654321
12345679012320987654321
1234567901234320987654321
123456790123454320987654321
12345679012345654320987654321
1234567901234567654320987654321
123456790123456787654320987654321
12345679012345678987654320987654321
1234567901234567900987654320987654321
123456790123456790120987654320987654321

Last edit: 2019-11-14 18:59:39
surajverma_19: 2019-10-31 16:04:50

Nice Problem
Solved it using sum of nth series using AP

tushargiri007: 2019-01-18 13:20:15

see pattern .liitle help from spoojtoolkit
just 7 lines code

sanyam19: 2018-06-19 11:24:09

just 4 line of code... :) just try to observe d pattern ..

n_o_o_b_i_e: 2018-06-17 12:44:36

take care of that eof condition

sinersnvrsleep: 2018-04-22 15:09:42

hats off to problem setter nice pattern

sandeep_4141: 2017-06-09 18:25:53

10 to 11 line code in c++

kass_97: 2017-01-06 13:00:01

Not much to do in this problem, just observe the pattern

aditya_rev: 2016-11-15 06:36:00

only 2 lines logic code:)

Amey Telawane: 2013-08-10 20:35:34

take pen and paper to get it accepted


Added by:Bin Jin
Date:2011-11-11
Time limit:0.200s
Source limit:4096B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64