#abc335g. G - Discrete Logarithm Problems
G - Discrete Logarithm Problems
Score : points
问题描述
给定 个整数 和一个质数 ,找出满足以下两个条件的整数对 的数量:
- ;
- 存在一个正整数 ,使得 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given integers and a prime number . Find the number of pairs of integers that satisfy both of the following conditions:
- ;
- There is a positive integer such that .
Constraints
- is prime.
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 13
2 3 5
Sample Output 1
5
Five pairs satisfy the conditions: .
For example, for the pair , if we take , then .
Sample Input 2
5 2
1 1 1 1 1
Sample Output 2
25
Sample Input 3
10 9999999999971
141592653589 793238462643 383279502884 197169399375 105820974944 592307816406 286208998628 34825342117 67982148086 513282306647
Sample Output 3
63
update @ 2024/3/10 01:24:39