如果有相应的OJ题目,欢迎同学们提供相应的链接

相关链接

简单的测试

None

代码模板

/*
* TIME COMPLEXITY:O(nlogm)
* PARAMS:
* a x==ai(mod mi)
* m
* n the number of equation.
*/
int crt(int a[],int m[],int n){
int M=1;
for(int i=0;i<n;i++) M*=m[i];
int ret=0;
for(int i=0;i<n;i++){
int x,y;
int tm=M/m[i];
extend_gcd(tm,m[i],x,y);
ret=(ret+tm*x*a[i])%M;
}
return (ret+M)%M;
}

模板-->中国剩余定理[互质版本]的更多相关文章

  1. 模板—中国剩余定理+拓展GCD

    int exgcd(int a,int b,int &x,int &y) { ) { x=,y=; return a; } int gcd=exgcd(b,a%b,x,y); int ...

  2. 中国剩余定理 CRT

    中国剩余定理 CRT 正常版本CRT 要解的是一个很容易的东西 \[ \begin{aligned} x\equiv a_1(mod\ m_1)\\ x\equiv a_2(mod\ m_2)\\ . ...

  3. Hello Kiki(中国剩余定理——不互质的情况)

    Hello Kiki Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Su ...

  4. poj 2981 Strange Way to Express Integers (中国剩余定理不互质)

    http://poj.org/problem?id=2891 Strange Way to Express Integers Time Limit: 1000MS   Memory Limit: 13 ...

  5. hdu X问题 (中国剩余定理不互质)

    http://acm.hdu.edu.cn/showproblem.php?pid=1573 X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory ...

  6. X问题(中国剩余定理+不互质版应用)hdu1573

    X问题 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  7. POJ 1006 Biorhythms --中国剩余定理(互质的)

    Biorhythms Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103539   Accepted: 32012 Des ...

  8. POJ 2891 中国剩余定理的非互质形式

    中国剩余定理的非互质形式 任意n个表达式一对对处理,故只需处理两个表达式. x = a(mod m) x = b(mod n) km+a = b (mod n) km = (a-b)(mod n) 利 ...

  9. Educational Codeforces Round 16 D. Two Arithmetic Progressions (不互质中国剩余定理)

    Two Arithmetic Progressions 题目链接: http://codeforces.com/contest/710/problem/D Description You are gi ...

随机推荐

  1. ueditor的过滤、转义、格式丢失问题

    1. 过滤 http://www.cnblogs.com/Olive116/p/3464495.html 2. 转义 http://segmentfault.com/q/101000000048928 ...

  2. Lua 5.1 for Delphi 2010

    This is a Lua 5.1 Wrapper for Delphi 2009 and Delphi 2010 which automatically creates OOP callback f ...

  3. C语言-01基础语法

    1)         总结常见文件的拓展名 .c 是C语言源文件,在编写代码的时候创建 .o 是目标文件,在编译成功的时候产生 .out 是可执行文件,在链接成功的时候产生 2)         总结 ...

  4. java高精度数组

    POJ1205 递推公式为a[i] = 3*a[i-1] - a[i-2], a[1] = 1,a[2] = 3 , i 最高为100; 搞懂了使用BigInteger开数组. import java ...

  5. 错误: 找不到或无法加载主类 scala.tools.nsc.MainGenericRunner

    错误: 找不到或无法加载主类 scala.tools.nsc.MainGenericRunner 原因: Sacala安装路径中包含空格.

  6. JVM系列五:JVM监测&工具

    JVM系列五:JVM监测&工具[整理中]  http://www.cnblogs.com/redcreen/archive/2011/05/09/2040977.html 前几篇篇文章介绍了介 ...

  7. 【转】onPrepareOptionsMenu 和onCreateOptionsMenu 的区别

    原文网址:http://blog.csdn.net/allenjy123/article/details/7467084 @Override public boolean onCreateOption ...

  8. 数据结构(线段树):Educational Codeforces Round 6 620E. New Year Tree

    E. New Year Tree time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...

  9. 动态规划(斜率优化):BZOJ 3675 [Apio2014]序列分割

    Description 小H最近迷上了一个分割序列的游戏.在这个游戏里,小H需要将一个长度为N的非负整数序列分割成k+l个非空的子序列.为了得到k+l个子序列, 小H将重复进行七次以下的步骤: 1.小 ...

  10. [转]stringstream的用法

    使用stringstream对象简化类型转换C++标准库中的<sstream>提供了比ANSI C的<stdio.h>更高级的一些功能,即单纯性.类型安全和可扩展性.在本文中, ...