#P1771. 方程的解
方程的解
Description
Jiajia ran into a tough problem and asks you to help solve it. Consider the Diophantine equation , where and , is a positive integer, and (that is, the remainder of modulo ). The numbers and are given. Your task is to find the number of solution tuples in positive integers to this equation.
For example, when , the solutions are:
Input Format
The input contains exactly one line with two positive integers separated by a space, namely .
Output Format
Output exactly one line with the number of solution tuples in positive integers.
3 2
3
Hint
- For 40% of the testdata, .
- For 100% of the testdata, , , .
NOI Journal 2010 Senior (01)
Translated by ChatGPT 5
京公网安备 11011102002149号