中国剩余定理
FSYo
我不去想是否能够成功,
既然选择了远方,
便只顾风雨兼程
展开
-
中国剩余定理
求解方程组 其中m互质 , 我们设 则通解为 t为任意整数 因为Mi与mi互质 所以令Mi^-1 为Mi 模mi的逆元 我们发现对于任意ai * Mi * Mi^-1 它模mi 为 ai 因为 Mi * Mi^-1 =1 https://www.luogu.org/problemnew/show/P3868 #include<bits/stdc++.h>...原创 2018-12-08 10:09:24 · 130 阅读 · 0 评论 -
扩展中国剩余定理
其中m不互质 我们假设前k-1个方程的一个解为ans 显然通解为ans + t * lcm , 其中lcm为前k-1项的最小公倍数 , t为任意整数 我们现在要求t 满足 也就是 转换为exgcd的形式 显然最后的t就是 解出来的t 乘一个 luogu4777 #include<bits/stdc++.h> #define N 100050 #defi...原创 2018-12-08 11:43:46 · 199 阅读 · 0 评论 -
Strange Way to Express Integers [扩展中国剩余定理]
Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following: Choose k different positive integers a1, ...原创 2018-12-08 14:50:57 · 188 阅读 · 0 评论