poj1061 2010.2.17
来源:互联网 发布:python 发送syslog 编辑:程序博客网 时间:2024/05/21 06:27
poj1061 2010.2.17
#include <iostream>using namespace std;__int64 x,y,m,n,l;__int64 modularLinearEquation(__int64 a,__int64 b,__int64 n);__int64 extEuclid(__int64 a, __int64 b);int main(void){__int64 s;scanf("%I64d",&x);scanf("%I64d",&y);scanf("%I64d",&m);scanf("%I64d",&n);scanf("%I64d",&l);s=modularLinearEquation((n-m+l)%l,(x-y+l)%l,l);if (s<0)printf("Impossible\n");elseprintf("%I64d\n",s);return 0;}__int64 modularLinearEquation(__int64 a,__int64 b,__int64 n){__int64 d,result;result=-1;d=extEuclid(a,n);if (b%d!=0) return result;x=x*(b/d);x=(x%(n/d)+n/d)%(n/d);result=x;return result;}__int64 extEuclid(__int64 a, __int64 b){__int64 r,t; if (b==0){ x=1;y=0;return a;} r=extEuclid(b,a%b);t=x; x=y; y=t-a/b*y; return r;}
0 0
- poj1061 2010.2.17
- POJ1061
- POJ1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- POJ1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1061
- poj1503 2010.2.17
- usaco holstein
- 北大培训课动态规划----神奇的口袋(百练2755)
- 高精度 A-B Problem
- [转] JAVA resultset
- poj1061 2010.2.17
- usaco milk2
- dsds
- usaco milk3
- poj2262 2010.2.17
- this方法获取a标签ID值及内容;idx传参
- UVa 1594 Ducci Sequence
- poj1129 2010.2.18
- usaco milk