PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000203. Số chữ số 0 cuối và số chữ số của giai thừa (How many zeroes and how many digits?)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số chữ số 0 cuối và số chữ số của giai thừa (How many zeroes and how many digits?)
Số chữ số 0 cuối và số chữ số của giai thừa (How many zeroes and how many digits?)
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given and base , write the integer in base . Determine (1) its number of trailing zero digits and (2) its total number of digits. By definition , which has one digit and no trailing zero.
Input
One line with two integers .
Output
Print the trailing-zero count and the total digit count separated by one space.
Subtasks
-
Subtask 1 (20 points): ; .
-
Subtask 2 (30 points): ; .
-
Subtask 3 (50 points): ; .
Examples
Example 1
Input
2 10
Output
0 1
Explanation
2!=2 has one decimal digit and no trailing zeros.
Example 2
Input
5 16
Output
0 2
Explanation
5!=120=78 in hexadecimal, which has two digits and no trailing zeros.
Example 3
Input
5 10
Output
1 3
Explanation
5!=120 has one trailing zero and three decimal digits.