题目大意:给出直线的一般式
Ax+By+C=0
的系数,求解在该直线上的一个整点。
题解:妈了个鸡就要联赛了,多刷刷这种裸算法题目有益身心健康,把背下来的扩展欧几里得打上去交一次就A掉了。
%%%__debug大神,保佑我联赛不挂。
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define X first
#define Y second
#define pii pair<int,int>
#define int long long
#define MP make_pair
#define DEBUG(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
int gcd(int a,int b)
{
return !b?a:gcd(b,a%b);
}
void exgcd(int a,int b,int& x,int& y)
{
if(!b)
{
x=1;y=0;return;
}
exgcd(b,a%b,y,x);y-=(a/b)*x;
}
main()
{
/*freopen("7C.in","r",stdin);
freopen("7C.out","w",stdout);*/
int a,b,c,x,y,d,t;
cin>>a>>b>>c;
d=gcd(a,b);
if(abs(c)%d!=0)
{
printf("-1\n");
return 0;
}
t=-c/d;
exgcd(a,b,x,y);
x*=t;y*=t;
cout<<x<<' '<<y<<endl;
}