#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
template<typename Tp> inline void read(Tp&x)
{
x=0;register bool z=1;
register char c=getchar();
for(;c<'0'||c>'9';c=getchar()) if(c=='-') z=0;
for(;'0'<=c&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
x=(z?x:~x+1);
}
int T,a,b,c,x,y;
int exgcd(int a,int b,int &x,int &y)
{
if(b==0) {x=1;y=0;return a;}
int d=exgcd(b,a%b,y,x);
y-=a/b*x;
return d;
}
signed main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
read(T);
while(T--)
{
read(a),read(b),read(c);
x=y=0;
int d=exgcd(a,b,x,y);
if(c%d)
{
cout<<-1<<endl;
continue;
}
x=((x*(c/d))%(b/d)+(b/d))%(b/d);
y=((y*(c/d))%(a/d)+(a/d))%(a/d);
cout<<c/d<<' '<<x<<' '<<y<<' '<<(c-y*b)/a<<' '<<(c-x*a)/b<<endl;
}
}
标签:临时,代码,register,long,getchar,define
From: https://www.cnblogs.com/Charlieljk/p/17935736.html