X-base question
Practice
0 (0 votes)
Open
Open
Medium
Combinatorics
Combinatorics basics
Basics of combinatorics
Mathematics
Open
Math
Problem
42% Success 120 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Let \(a_i\) be the number of digits in the x-base representation of \(i\). The x-base representation is the representation of a number in base \(x\).
Determine the \(\displaystyle\sum_{i=0}^{n} {a_i}\) for the provided \(n\) and \(x\).
Input format
- First line: A single integer \(t\)
- Each of the next \(t\) lines: Two space-separated integers \(n\) and \(k\)
Output format
For each test case, print a single integer that represents the answer to the question. Print the integers as space-separated integers on a single line.
Constraints
\(1 \le t \le 10^3\)
\(1 \le n \le 10^{15}\)
\(1 \le k \le 10^4\)
Submissions
Please login to view your submissions
Similar Problems
Points:30
12 votes
Tags:
Advanced Data StructuresCombinatoricsData StructuresFenwick treeMedium普通
Points:50
37 votes
Tags:
Data StructuresDisjoint setGraphsMapsMediumReadyTrees
3.War
Points:20
87 votes
Tags:
ApprovedBasic ProgrammingEasyOpen
Editorial