JCC25 Contest 2 P5 - Jimmy's Math Challenge


Submit solution

Points: 7
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Thanks to your rapid work, Jimmy was able to recover safely from the acute pascal syndrome.

On his first day back to school, someone decided to challenge Jimmy with a math problem. After struggling on it for days, he has come to you for desperate help.

The question is as follows:

Given an arithmetic sequence with a common difference \(D\), a first term of \(1\), and an integer \(K\), find the \(K\)th digit of the arithmetic sequence.

Constraints

\(1 \leq D \leq 10^{3}\)

Subtask 1 [30%]

\(1 \leq K \leq 10^{6}\)

Subtask 2 [70%]

\(1 \leq K \leq 10^{12}\)

Input Specification

The first line will contain two integers, \(D\) and \(K\).

Output Specification

Output the \(K\)th digit of the sequence.

Sample Input:

4 5

Sample Output:

3

Explanation:

The arithmetic sequence is \(1\), \(5\), \(9\), \(13\), \(17\), \(21\), … The \(5\)'th digit is \(3\).


Comments

There are no comments at the moment.