TopCoder SRM 657 Div2 Problem 1000 - PolynomialRemainder(数学)
来源:互联网 发布:网络作家富豪榜 编辑:程序博客网 时间:2024/06/08 11:32
题意
求x,使得
思路
看了别人的代码,马后炮一下。有什么不对的地方欢迎指出。
要使得
我们先求出x1、x2,使得代入二次方程之后的结果分别
如果
那么此时x2就是符合条件的。
代码
class PolynomialRemainder {public: LL Calcu(LL a, LL b, LL c, LL k) { for (int i = 0; i < k; i++) if ((a*i%k*i + b*i%k + c) % k == 0) return i; return -1; } int findRoot(int a, int b, int c) { int mul_2 = 1, mul_5 = 1; for (int i = 0; i < 9; i++) mul_2 *= 2; for (int i = 0; i < 9; i++) mul_5 *= 5; LL p1 = Calcu(a, b, c, mul_2); LL p2 = Calcu(a, b, c, mul_5); if (p1 == -1 || p2 == -1) return -1; while (p2 % mul_2 != p1) p2 += mul_5; return p2; }};
0 0
- TopCoder SRM 657 Div2 Problem 1000 - PolynomialRemainder(数学)
- TopCoder SRM 668 Div2 Problem 1000 - AnArray (数学)
- TopCoder SRM 634 Div2 Problem 1000 - SpecialStrings
- TopCoder SRM 657 Div2 Problem 500 - ProblemSetsEasy (二分 + 模拟)
- TopCoder SRM 648 Div2 Problem 1000 - ABC (DP)
- TopCoder SRM 649 Div2 Problem 1000 - XorSequenceEasy (思维)
- TopCoder SRM 652 Div2 Problem 1000 - NoRightTurnDiv2 (几何 + 贪心)
- TopCoder SRM 660 Div2 Problem 1000 - Powerit (数论)
- TopCoder SRM 663 Div2 Problem 1000 - CheeseRolling (状压dp)
- TopCoder SRM 672 Div2 Problem 1000 - Tdetectived2 (状压dp)
- TopCoder SRM 633 Div2 Problem 500 - Jumping
- TopCoder SRM 634 Div2 Problem 500 - ShoppingSurvey
- Topcoder SRM 663 Div2 Problem 500
- Topcoder SRM 635 div2 1000
- Topcoder SRM 636 div2 1000
- Topcoder SRM 640 Div2 1000(巧妙数学题)
- Topcoder SRM 517 DIV2 1000 CuttingGrass
- Topcoder SRM 566 DIV2 1000 FencingPenguinsEasy
- LightOJ1079---Just another Robbery (概率做01背包)
- python C/S模式基础编程 (网络安全系列)
- 关于Android中Alertdialog中的EditText输入问题
- HDU 4715 Difference Between Primes
- 快速理解Linux下僵死进程、孤儿进程和守护进程及无名管道
- TopCoder SRM 657 Div2 Problem 1000 - PolynomialRemainder(数学)
- orcle创建自增列
- tp3.2 实现 PHPExcel 上传 下载
- 代码规范的重要性:2015年-4月-29日调试教训 即 经验
- VS2010编译错误:fatal error C1189: #error : This file requires _WIN32_WINNT to be #defined at least to 0x
- bug.150429
- SQL中Group By的使用
- 为什么要使用线程池
- 你的C/C++程序为什么无法运行?揭秘Segmentation fault (2)