New Self-describing Sequence

TimeLimit:5000MS  MemoryLimit:262144KB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description
Let $a_1, a_2$,... be an integer sequence beginning with $a_1$ = 1. For n ≥ 1, $a_n$+1 is the sum of an and the sum of digits of $a_n$. That’s why we name the sequence a new Self-describing sequence.
The sequence starts with 1, 2, 4, 8, 16, 23, 28, 38, 49, ... and we also define the prefix sum $s_n = a_1 + a_2 + ... + a_n$.
For given positive integer n, find $a_n$ and $s_n$.
Input
The first line of input consists an integer T (T ≤ 32768), indicating the total number of test cases. Each of the following T lines provides an integer n (n ≤ 10^17).
Output
For each test case output its case label first. Then for given n, output $a_n$ and $s_n$. Since the prefix sum is large,you only need to output $s_n$ mod 1000000009. However you should output $a_n$ as its exact value.
SampleInput
7
6
66
666
6666
66666
123456789
31415926535897932
SampleOutput
Case #1: 23 54
Case #2: 752 20862
Case #3: 10949 3407733
Case #4: 136193 441127485
Case #5: 1698899 717710112
Case #6: 5061289531 990040993
Case #7: 2508156610654066874 660828136
Submit
题目统计信息详细
总AC数0
通过人数0
尝试人数0
总提交量0
AC率0.00%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
出处

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: