P28886 [洛谷] The Magical Radix of Toxicity
提高
题目描述

Background

Mangrove 2363 Expert is Building a Computer

(CYJian: zrz, stop using your crappy input method for these pinyin games... We can still tell it's hsl2363..)

Problem Description

The 2363 Expert, feeling quite disappointed, discovered that computers are great for van (fun). He decided to build one himself. After completing it, a novice with responsibility came along, and the 2363 Expert told him:

"My computer operates in X-* radix. I really want to know how inexperienced you are, so I'm asking you to convert a few numbers from my computer's radix to decimal."

The X-* radix works by subtracting the ASCII value of '0' from each digit's ASCII value and then multiplying by X raised to the power of i, and then multiplying all these values together. (It's a bit confusing, so see the explanation below.)

For example:

3 2363

Converted to decimal, it becomes $2 * 3^3 * 3 * 3^2 * 6 * 3^1 * 3 * 3^0$

The novice found it too difficult and threw it to you.

Since the answer might be very large, output the number of digits of the answer (wink).

Input Format

An integer Q representing the number of questions.

Next, Q lines, each containing an integer a representing the X-* radix, and a string s representing the number.

Output Format

A single line containing an integer representing the answer.

Sample Input and Output

Sample Input #1

1
1 11

Sample Output #1

1

Sample Input #2

1
2 a45

Sample Output #2

4

Notes

1 ≤ Q ≤ 100
1 ≤ a ≤ 100000 and is equal to the length of the string minus one.

The data has varying difficulties, but I won't tell you.

$$\color{white}{\text{If you want to brute force, high precision is impossible without it}}$$

The data guarantees that there is no '0' in the string.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
1 1 11
样例输出
1