poj 1061 青蛙的约会 二元一次不定方程 http://poj.org/problem?id=1061
来源:互联网 发布:网络重口现场微博 编辑:程序博客网 时间:2024/05/16 01:58
#include<iostream>using namespace std;typedef long long inta;int extend_gcd(inta a,inta b,inta &x,inta &y,inta &gcd){ if(b==0) { x=1; y=0; gcd=a; } else { extend_gcd(b,a%b,x,y,gcd); int temp=x; x=y; y=temp-a/b*y; }}int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ inta x,y,m,n,l; while(cin>>x>>y>>m>>n>>l) { inta a=n-m; inta b=l; inta c=x-y; inta s=gcd(a,b); if(c%s!=0) { cout<<"Impossible"<<endl; } else { inta x0,y0,q; a/=s; b/=s; c/=s; extend_gcd(a,b,x0,y0,q); x0*=c; if(b<0) b=-b; x0=(x0%b+b)%b; cout<<x0<<endl; } }}
// 1 扩展欧几里得算法,利用递归求出 Bezout等式中x和y的值
// 2 不知道a的正负性时a mod b=(a%b+b0%b
// 3 ax+by=c; gcd(a,b)=1; x的通解模b同余,要求取最下的非负整数就在完系中取即可
- poj 1061 青蛙的约会 二元一次不定方程 http://poj.org/problem?id=1061
- 青蛙的约会&&http://poj.org/problem?id=1061
- poj 1061 青蛙的约会 拓展欧几里德 解二元一次不定方程
- POJ 1061 青蛙的约会 扩展欧几里得http://poj.org/problem?id=1061
- poj 1061 青蛙的约会(扩展欧几里得解不定方程)
- poj1061 青蛙的约会 解二元一次不定方程
- POJ 1061 青蛙约会(一次同余方程)
- poj 1061 青蛙的约会(扩展欧几里德解不定方程)
- poj 1061 青蛙的约会(gcd拓展,解不定方程)
- 【原创】用拓展欧几里得解不定方程 ※POJ-1061-青蛙的约会
- Poj 1061 青蛙的约会 数论 欧几里得 求余方程
- poj 1061 青蛙的约会 (解同余方程)
- POJ 1061 青蛙的约会 同余方程
- POJ 1061 青蛙的约会 一元线性同余方程
- POJ 1061 青蛙的约会
- poj 1061 青蛙的约会
- POJ 1061 青蛙的约会
- poj 1061 青蛙的约会
- The Android Telephony API for GSM
- C语言相对于C++不具有的性质
- Could not find the main class. Program will exit
- iOS 获取本地IP地址
- alias 命令的用法
- poj 1061 青蛙的约会 二元一次不定方程 http://poj.org/problem?id=1061
- 关于 linux 的环境变量设置及 export 的用法
- LINUX下性能分析工具简单介绍
- 2013-07-03
- CActiveDataProvider, CArrayDataProvider, CSqlDataProvider填充CGridView数据经验谈
- VLFeat SIFT with OpenCV + Code
- How to convert an OpenCV cv::Mat into a float* that can be fed into Vlfeat vl_dsift_process ?
- CareerCup 4.5
- 字段名称不能是group,至少sqlite中,保留关键字?