X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2980    Accepted Submission(s): 942 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod…
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…
X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5221    Accepted Submission(s): 1761 Problem Description 求在小于等于N的正整数中有多少个X满足:X mod a[0] = b[0], X mod a[1] = b[1], X mod a[2] = b[2], …, X mod…
中国剩余定理的非互质形式 任意n个表达式一对对处理,故只需处理两个表达式. x = a(mod m) x = b(mod n) km+a = b (mod n) km = (a-b)(mod n) 利用扩展欧几里得算法求出k k = k0(mod n/(n,m)) = k0 + h*n/(n,m) x = km+a = k0*m+a+h*n*m/(n,m) = k0*m+a (mod n*m/(n,m)) #include <cstdio> #include <cstring> #…
http://acm.hdu.edu.cn/showproblem.php?pid=5072 求n个不同的数(<=1e5)中有多少组三元组(a, b, c)两两不互质或者两两互质. 逆向求解,把所有不符合的情况求出来用总的情况数减去即可: 先用容斥求出和a[i] 互质的个数num ,然后不符合条件的 就是 num*(n-1-num); 求法见http://blog.csdn.net/u012774187/article/details/40399567 #include <cstdio>…
分析:考虑对给定的出圈序列进行一次模拟,对于出圈的人我们显然可以由位置,编号等关系得到一个同余方程 一圈做下来我们就得到了n个同余方程 对每个方程用扩展欧几里得求解,最后找到最小可行解就是答案. 当然不要忘了判无解的情况. 有非常多选手似乎都是一眼标算然后写挂了,对此表示很遗憾,但是此题确实是比较容易写挂的... 注:中国剩余定理 解模线性方程组的时候 有两种情况 1:一种是模数是两辆互质的,这样的题可以用LRJ白书上的模板,俗称CRT1 2:模数存在不互质的,这样的需要用合并方程的做法,俗称C…
Hello Kiki Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description One day I was shopping in the supermarket. There was a cashier counting coins seriously when a little kid running and singing "门前大桥下游过一…
题意:给你余数和除数求x 注意除数不一定互质 思路:不互质的CRT需要的是将两个余数方程合并,需要用到扩展GCD的性质 合并互质求余方程 m1x -+ m2y = r2 - r1 先用exgcd求出特解x0, y0(m1x + m2y = g) 等式两边都乘以c/g 那么可以得解为 x1 = cx0/g,y1 = cy0/g 由性质可知 通解x' = x1 + km2/g,y' = y1 + km1/g 其中k为任意整数 即 x' = cx0/g + km2/g 设 t = m2/g 为保证x是…
As we all know, the next Olympic Games will be held in Beijing in 2008. So the year 2008 seems a little special somehow. You are looking forward to it, too, aren't you? Unfortunately there still are months to go. Take it easy. Luckily you meet me. I…
Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 8176   Accepted: 2439 Description Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is…