HDU 2669 Romantic 拓展欧几里得模板题
来源:互联网 发布:mac上的绘画软件 编辑:程序博客网 时间:2024/05/29 04:53
初学欧几里得,帮助理解。。
这里的x要为最小正整数,求出x然后又等式得到y。
#include<iostream>#include<cstdio>using namespace std;typedef long long LL;void gcd(LL a,LL b,LL &d,LL &x,LL &y){if(!b) {d=a,y=0,x=1;}else{gcd(b,a%b,d,y,x);y-=x*(a/b);}}int main(){//freopen("E:\\ACM\\test.txt","r",stdin);LL a,b,d,x,y,c=1;while(cin>>a>>b){gcd(a,b,d,x,y);if(c%d) puts("sorry"); //c不是d的倍数则没有整数解 else{x*=c/d; //得到特解b/=d;x=(x%b+b)%b; //求最小正整数解x y=(1-a*x)/b; //由等式推出y cout<<x<<" "<<y<<endl; }}return 0;}
阅读全文
0 0
- HDU 2669 Romantic 拓展欧几里得模板题
- HDU 2669 Romantic 扩展欧几里得模板题@
- HDU 2669 Romantic(拓展欧几里得)
- hdu 2669 Romantic 扩展欧几里得求线性方程模板题
- HDOJ 题目2669 Romantic(拓展的欧几里得,模板)
- HDU 2669 Romantic【扩展欧几里得板子题】
- HDU 2669 Romantic 扩展欧几里得
- HDU 2669 Romantic(扩展欧几里得)
- HDU 2669 Romantic (扩展欧几里得)
- hdu 2669 Romantic 扩展欧几里得
- HDU 2669 Romantic [扩展欧几里得]
- HDU 2669 Romantic扩展欧几里得
- hdu 2669(拓展欧几里得)
- HDU-2669 拓展欧几里得
- HDU 2669 Romantic (扩展欧几里得定理)
- 扩转欧几里得算法 hdu 2669 Romantic
- [数论]HDU 2669 Romantic 扩展欧几里得算法
- hdu - 2669 - Romantic(扩展欧几里得)
- 单调递增最长子序列(一)
- java 中的 final 关键字
- Css3响应式布局
- Docker run终端交互能力
- CSS3浮动与清除浮动
- HDU 2669 Romantic 拓展欧几里得模板题
- PHPcms模板编译过程
- xaml实现可拖拽的分割栏
- Mixed Content: The page was loaded over HTTPS,blocked the content must be served over HTTPS.
- 微信自定义菜单
- SVM公式推导
- T-聊天止于呵呵
- CentOS7安装KVM虚拟机详解
- 自定义注解,利用反射进行解析