Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 9472   Accepted: 2873 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is…
Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 16839   Accepted: 5625 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is…
Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 10907   Accepted: 3336 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is…
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, a2, …, ak. For some non-negative m, divide it by ev…
http://poj.org/problem?id=2891 题意:求解一个数x使得 x%8 = 7,x%11 = 9; 若x存在,输出最小整数解.否则输出-1: ps: 思路:这不是简单的中国剩余定理问题,由于输入的ai不一定两两互质,而中国剩余定理的条件是除数两两互质. 这是一般的模线性方程组,对于 X mod m1=r1 X mod m2=r2 ... ... ... X mod mn=rn 首先,我们看两个式子的情况 X mod m1=r1-----------------------(…
http://poj.org/problem?id=2891 题意就是孙子算经里那个定理的基础描述不过换了数字和约束条件的个数…… https://blog.csdn.net/HownoneHe/article/details/52186204 这个博客提供了互质情况下的代码以及由此递推出的(另一个版本的)非互质情况下的代码. 假如给出m[n],a[n]分别代表要求的除数和余数: 互质情况下: ( 做n次 ) 对不包含m[i]的所有m求积 ( 互质的数的最小公倍数 ) , exgcd求出来逆元后…
http://poj.org/problem?id=2891 711323 97935537 475421538 1090116118 2032082 120922929 951016541 15898 418373 161478614 149488440 1748022751 21618619576 810918992 241779667 1772616743 1953316358 125248280 2273149397 3849022001 2509433771 3885219405 35…
题目链接:http://poj.org/problem?id=2891 题目大意: 求解同余方程组,不保证模数互质 题解: 扩展中国剩余定理板子题 #include<algorithm> #include<cstring> #include<cstdio> #include<iostream> #include<cmath> using namespace std; typedef long long ll; +; int k; ll m[N],…
求解方程组 X%m1=r1 X%m2=r2 .... X%mn=rn 首先看下两个式子的情况 X%m1=r1 X%m2=r2 联立可得 m1*x+m2*y=r2-r1 用ex_gcd求得一个特解x' 得到X=x'*m1+r2 X的通解X'=X+k*LCM(m1,m2) 上式可化为:X'%LCM(m1,m2)=X 到此即完成了两个式子的合并,再将此式子与后边的式子合并,最后的得到的X'即为答案的通解,求最小整数解即可. #include<stdio.h> #include<string.h…
题目链接 虽然我不懂... #include <cstdio> #include <cstring> #include <map> #include <cmath> using namespace std; #define LL __int64 LL p[],o[]; LL x,y; LL ext_eulid(LL a,LL b) { LL t,d; ) { x = ; y = ; return a; } d = ext_eulid(b,a%b); t =…