for quite some time and finally I found some time to get
back to it.
Here is some sample I/O for anyone who might be interested.
INPUT
Code: Select all
18
0
1
54
12575
312544
808080777
110010
99999
878787878
1112143
234000243
999999999
777777777
101010101
1000000000
2000000000
1234567890
2147483647
OUTPUT
Code: Select all
1
1
317683
1041390301833851
397580508821554746073
17766744538362351421688193776113027
6102302473357942756
4166250019582975003
24849919480110185721478177782865879
63742478475498293889839
124926329720184395503853225251864
41666666250000001958333329750000003
15247929506896815534083978943771277
4337584555967507575973509760476
41666666416666667624999999250000001
666666664666666670499999998500000001
96794050695522260242568330014498846
886151993063477126682488902248300547