#abc322g. G - Two Kinds of Base
G - Two Kinds of Base
Score : points
问题描述
对于一个非负整数序列 和一个整数 ,我们定义函数 如下:
- 。
例如,$f((1,2,3),4) = 1 \times 4^2 + 2 \times 4^1 + 3 \times 4^0 = 27$,并且 $f((1,1,1,1),10) = 1 \times 10^3 + 1 \times 10^2 + 1 \times 10^1 + 1 \times 10^0 = 1111$。
给定正整数 和 。求满足以下所有条件的非负整数序列 和正整数 、 组成的三元组 的个数,结果对 取模。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
For a non-negative integer sequence and an integer , we define the function as follows:
- .
For example, $f((1,2,3),4) = 1 \times 4^2 + 2 \times 4^1 + 3 \times 4^0 = 27$, and $f((1,1,1,1),10) = 1 \times 10^3 + 1 \times 10^2 + 1 \times 10^1 + 1 \times 10^0 = 1111$.
You are given positive integers and . Find the number, modulo , of triples of a sequence of non-negative integers and positive integers and that satisfy all of the following conditions.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the number, modulo , of triples of a sequence of non-negative integers and positive integers and that satisfy the conditions.
Sample Input 1
4 2
Sample Output 1
5
The five triples $(S,a,b)=((1,0),4,2),((1,1),4,2),((2,0),4,3),((2,1),4,3),((2,2),4,3)$ satisfy the conditions.
Sample Input 2
9 30
Sample Output 2
31
Sample Input 3
322322322 200000
Sample Output 3
140058961
update @ 2024/3/10 01:43:33