CodeForces 7C Line (扩展欧几里得)
2015-04-02 22:33
337 查看
前面忘记修改gcd,一直求不出来。。。套套模板轻松水,,
#include "string" #include "iostream" #include "cstdio" #include "cmath" #include "set" #include "queue" #include "vector" #include "cctype" #include "sstream" #include "cstdlib" #include "cstring" #include "stack" #include "ctime" #include "algorithm" #define pa pair<int,int> #define Pi M_PI #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef long long LL; const int M=55; LL x,y; LL exgcd(LL a,LL b) { LL t,d; if(b==0) { x=1; y=0; return a; } d=exgcd(b,a%b); t=x; x=y; y=t-(a/b)*y; return d; } int main() { LL a,b,c,d; while(cin>>a>>b>>c) { if(exgcd(a,b)!=1) cout<<-1<<endl; else { x=-x*(c/d); y=-y*(c/d); cout<<x<<' '<<y<<endl; } } return 0; }
相关文章推荐
- codeforces 7c line(扩展欧几里得)
- CodeForces 7 C. Line(扩展欧几里得)
- Codeforces 7C 扩展欧几里得
- Codeforces 724C Ray Tracing 扩展欧几里得
- CodeForces - 7C Line(扩展欧几里得)
- CodeForces 7C【扩展欧几里得】
- CodeForces 7C (扩展欧几里得)
- codeforces 612A The Text Splitting(扩展欧几里得)
- CodeForces - 7C Line(扩展欧几里得模板)
- 扩展欧几里得--解一元线性方程CodeForces -7C
- codeforces 787A the monster(扩展欧几里得做法+暴力做法)
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
- ☆ Codeforces 724C Ray Tracing 扩展欧几里得 + 计算几何
- Codeforces 724C Ray Tracing 扩展欧几里得
- CodeForces 724|模拟|贪心|扩展欧几里得|
- 【数论】【扩展欧几里得】Codeforces 710D Two Arithmetic Progressions
- [codeforces 200 E Tractor College]枚举,扩展欧几里得,三分
- CodeForces 787A A. The Monster(扩展欧几里得)
- The equation - SGU 106(扩展欧几里得)
- 欧几里得模板以及扩展欧几里得