POJ1061
来源:互联网 发布:java入门123 编辑:程序博客网 时间:2024/05/19 07:27
拓展欧几里得解线性方程组
#include "iostream"#include "cstdio"using namespace std;long long d;long long GcdFull(long long a,long long b,long long &x,long long &y){if (b == 0){x = 1;y = 0;return a;}long long g = GcdFull(b,a % b,x,y);long long t = x;x = y;y = t - (a / b) * y;return g;}int main(void){long long a,b,x,y,l,m,n,gcd;long long s1,s2;while(cin >> x >> y >> m >> n >> l){a = n - m;b = l;d = x - y;if ( d % (gcd = GcdFull(a,b,s1,s2))){printf("Impossible\n");}else{b /= gcd;d /= gcd;s1 = ((s1 * d ) % b + b) % b;printf("%lld\n",s1);}}return 0;}
- POJ1061
- POJ1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- POJ1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- POJ1061
- linux调度器(二)——CFS模型
- POJ1007
- Struts2教程二——Hello World Using Struts 2
- POJ1046
- linux调度器(三)——周期性调度器与CFS
- POJ1061
- POJ1077八数码问题哈希,bfs
- linux调度器(四)——主调度器与CFS
- 新东方六级12-12
- linux调度器(五)——进程管理与CFS
- POJ1118
- Ubuntu下使用valgrind检测内存泄露流程
- linux调度器(六)——应用层理解CFS及组调度
- 桥接模式(Bridge)