博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
中国剩余定理
阅读量:4328 次
发布时间:2019-06-06

本文共 1409 字,大约阅读时间需要 4 分钟。

#include
using namespace std;vector
> equation_set;int get_inv(int n,int x){ int nn=n; x=x%n; pair
X(0,1),N(1,0); while(x){ N={N.first-n/x*X.first,N.second-n/x*X.second}; n=n%x; swap(n,x); swap(N,X); } if(n==1)return (N.second%nn+nn)%nn; else return 0;}int degrade(int n,int x){ for(int i=2,p=1;i*i<=n;++i,p=1){ if(n%i)continue; while(n%i==0){ p*=i; n/=i; } equation_set.emplace_back(p,x%p); } if(n>1)equation_set.emplace_back(n,x%n);}void print_equation_set(){ for(auto &a: equation_set) cout<<"x = "<
<<" (mod "<
<<")\n";}int main(){ ios::sync_with_stdio(0); int n,x,num; cout<<"=======================================\n"; cout<<"equation number: "; while(cin>>num){ cout<<"# if x=a(mod b), then input b a\n"; equation_set.clear(); //input while(num--){ cin>>n>>x; degrade(n,x%n); } //output sort(equation_set.begin(),equation_set.end()); cout<<"\ndegraded equations:\n"; print_equation_set(); //arrange vector
> tmp; vector
vis(equation_set.size(),false); bool error=false; for(int i=0,j,last;i

转载于:https://www.cnblogs.com/maoruimas/p/10604695.html

你可能感兴趣的文章
su 与 su - 区别
查看>>
C语言编程-9_4 字符统计
查看>>
在webconfig中写好连接后,在程序中如何调用?
查看>>
限制用户不能删除SharePoint列表中的条目(项目)
查看>>
【Linux网络编程】使用GDB调试程序
查看>>
feign调用spring clound eureka 注册中心服务
查看>>
ZT:Linux上安装JDK,最准确
查看>>
LimeJS指南3
查看>>
关于C++ const成员的一些细节
查看>>
《代码大全》学习摘要(五)软件构建中的设计(下)
查看>>
C#检测驱动是否安装的问题
查看>>
web-4. 装饰页面的图像
查看>>
微信测试账户
查看>>
Android ListView上拉获取下一页
查看>>
算法练习题
查看>>
学习使用Django一 安装虚拟环境
查看>>
Hibernate视频学习笔记(8)Lazy策略
查看>>
CSS3 结构性伪类选择器(1)
查看>>
IOS 杂笔-14(被人遗忘的owner)
查看>>
自动测试用工具
查看>>