51Nod--1014 X^2 Mod P
2017-06-13 00:39
225 查看
题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1014
基准时间限制:1 秒 空间限制:131072 KB
X*X mod P = A,其中P为质数。给出P和A,求<=P的所有X。
Input
两个数P A,中间用空格隔开。(1 <= A < P <= 1000000, P为质数)
Output
输出符合条件的X,且0 <= X <= P,如果有多个,按照升序排列,中间用空格隔开。
如果没有符合条件的X,输出:No Solution
Input示例
13 3
Output示例
4 9
采用直接枚举就行了,因为其时间复杂度是百万级的,1秒可以过:
基准时间限制:1 秒 空间限制:131072 KB
X*X mod P = A,其中P为质数。给出P和A,求<=P的所有X。
Input
两个数P A,中间用空格隔开。(1 <= A < P <= 1000000, P为质数)
Output
输出符合条件的X,且0 <= X <= P,如果有多个,按照升序排列,中间用空格隔开。
如果没有符合条件的X,输出:No Solution
Input示例
13 3
Output示例
4 9
采用直接枚举就行了,因为其时间复杂度是百万级的,1秒可以过:
#include <iostream> #include <cmath> using namespace std; const long long N = 1000010; int main() { int count = 0; int p, a; cin >> p >> a; for(long long i = 1; i <= p; i++) { if(i*i % p == a) { if(count++) { cout << " "; } cout << i; } } if(count == 0) { cout << "No Solution"; } return 0; }
相关文章推荐
- 51nod 1014 X^2 Mod P
- 51nod 1014 X^2 Mod P
- 51Nod 1014 X^2 Mod P
- 51nod 1014 X^2 Mod P
- 【51Nod】1014 X^2 Mod P
- 51Nod-1014 X^2 Mod P【暴力】
- 51nod-1014 X^2 Mod P(二次剩余。。求解决)
- 51Nod 1014 X^2 Mod P
- 51Nod 1014 X^2 Mod P
- 51nod 1014 X^2 Mod P
- 51nod 1014 X^2 Mod P 预处理瞎搞
- 51nod-【1014 X^2 Mod P】
- 51nod 1126 求循环节 注意mod与%区别
- 【51Nod-1008】N的阶乘 mod P
- 1014 X^2 Mod P(数论 枚举)(2级算法题)
- 【51NOD-0】1008 N的阶乘 mod P
- 51nod 1014 X^2 Mod P
- 51nod 1014 X^2 Mod P【暴力】
- 【51Nod】1008 N的阶乘 mod P
- 51Nod--1008 N的阶乘 mod P