Problem:
Problem C:Champernowne Constant

Champernown constant is an irrational number represented in decimal by "0." followed by
concatenation of all positive integers in the increasing order. The first few digits of this constant
are: 0.123456789101112...

Your task is to write a program that outputs the K digits of Chapnernown constant starting at
the N-th place for given two natural numbers K and N.

Input

The input has multiple lines. Each line has two positive integers N and K (N ≤ 109, K ≤ 100)
separated by a space.

The end of input is indicated by a line with two zeros. This line should not be processed.

Output

For each line, output a line that contains the K digits.

Sample Input

4 5
6 7
0 0

Output for the Sample Input

45678
6789101

Solution in C# (judge verdict: Accepted)

using System.Text;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        var a = new long[11];
        var b = new long[11];
        a[0] = 9 * 1; b[0] = a[0];
        for (int i = 1; i < 11; i++)
        {
            a[i] = (i + 1) * 9 * (long)Pow(10, i);
            b[i] = a[i] + b[i - 1];
        }
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var k = int.Parse(line[1]);
            if (n == 0 && k == 0) break;
            var t1 = 0;
            for (int i = 0; i < 11; i++)
                if (b[i] >= n) { t1 = i; break; }
            var t2 = t1 == 0 ? n - 1 : n - b[t1 - 1] - 1;
            var t3 = t2 / (t1 + 1);
            var t4 = t2 % (t1 + 1);
            var t5 = (int)Pow(10, t1) + t3;
            var t6 = t5.ToString().Substring((int)t4);
            putAns(k, (int)t5, t6);
        }
    }
    static void putAns(int k, int t5, string t6)
    {
        var sb = new StringBuilder();
        sb.Append(t6);
        var p = t5 + 1;
        while (sb.Length < k)
        {
            sb.Append((p++).ToString());
        }
        Console.WriteLine(sb.ToString().Substring(0, k));
    }
}