BZOJ 1406: [AHOI2007]密码箱
2017-09-07 19:12
417 查看
二次联通门 : BZOJ 1406: [AHOI2007]密码箱
/* BZOJ 1406: [AHOI2007]密码箱 数论 要求 x^2 ≡ 1 (mod n) 可以转换为 x ^ 2 - k *n = 1 (x + 1) * (x - 1) = k * n 设 n = a * b 则 a * b | (x + 1) * (x - 1) 那么枚举b即可 */ #include <cstdio> #include <cmath> #include <set> typedef long long LL; #define Set std :: set <LL> int main () { LL N, a, b; scanf ("%lld", &N); register LL i, j; int L = sqrt (N); Set Answer; for (i = 1; i <= L; ++ i) if (N % i == 0) { a = i, b = N / i; for (j = 0; j <= N; j += b) { if ((j + 2) % a == 0 && j + 2 < N) Answer.insert (j + 1); if ((j - 2) % a == 0 && j - 2 >= 0) Answer.insert (j - 1); } } if (Answer.size () == 0) return printf ("None"), 0; for (Set :: iterator i = Answer.begin (); i != Answer.end (); ++ i) printf ("%lld\n", *i); return 0; }
相关文章推荐
- [BZOJ1406][AHOI2007]密码箱(数学相关)
- 【BZOJ】1406: [AHOI2007]密码箱
- BZOJ1406: [AHOI2007]密码箱
- bzoj 1406: [AHOI2007]密码箱
- BZOJ1406[AHOI2007密码箱]
- BZOJ 1406 [AHOI2007]密码箱 数论
- bzoj 1406: [AHOI2007]密码箱 二次剩餘
- bzoj1406: [AHOI2007]密码箱
- bzoj 1406: [AHOI2007]密码箱 数学
- BZOJ 1406 AHOI2007 密码箱 数论
- BZOJ_1406_[AHOI2007]密码箱_枚举+数学
- bzoj 1406: [AHOI2007]密码箱
- [数论] BZOJ 1406 [AHOI2007]密码箱
- BZOJ-1406-密码箱-AHOI2007-数学
- BZOJ1406 [AHOI2007]密码箱
- 【BZOJ 1406】 [AHOI2007]密码箱
- BZOJ 1406: [AHOI2007]密码箱( 数论 )
- 【BZOJ 1406】【AHOI 2007】密码箱
- BZOJ1406 [AHOI2007]密码箱
- 【二次剩余】【bzoj 1406】: [AHOI2007]密码箱