47 lines
756 B
C++
47 lines
756 B
C++
|
#include <iostream>
|
|||
|
#include<cstdio>
|
|||
|
#include<algorithm>
|
|||
|
#include <cmath>
|
|||
|
#include <cstdlib>
|
|||
|
using namespace std;
|
|||
|
long long exgcd(long long a,int b,int &x,int &y)
|
|||
|
{
|
|||
|
if(b==0)
|
|||
|
{
|
|||
|
//x,yû<79><C3BB><EFBFBD><EFBFBD>ֵ
|
|||
|
x=1;
|
|||
|
y=0;
|
|||
|
return a;
|
|||
|
}
|
|||
|
int ret=exgcd(b,a%b,x,y);
|
|||
|
int tmp=x;
|
|||
|
x=y;
|
|||
|
y=tmp-a/b*y;
|
|||
|
return ret;
|
|||
|
}
|
|||
|
int main()
|
|||
|
{
|
|||
|
int a,b,c;
|
|||
|
while(~scanf("%d%d%d",&a,&b,&c))
|
|||
|
{
|
|||
|
if(a==0&&b==0&&c==0)
|
|||
|
{
|
|||
|
break;
|
|||
|
}
|
|||
|
int x0,y0;
|
|||
|
int g=exgcd(a,b,x0,y0);
|
|||
|
int x1=(c/g*x0%(b/g)+b/g)%(b/g),y1=(c-a*x1)/b;
|
|||
|
int y2=(c/g*y0%(a/g)+a/g)%(a/g),x2=(c-b*y2)/a;//<2F><>a
|
|||
|
x1=abs(x1);x2=abs(x2);y1=abs(y1);y2=abs(y2);//abs()<29><>C<EFBFBD><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֻ<EFBFBD><D6BB>int<6E><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
|
|||
|
if(x1+y1<x2+y2||a*x1+b*y1<a*x2+b*y2)
|
|||
|
{
|
|||
|
printf("%d %d\n",x1,y1);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
printf("%d %d\n",x2,y2);
|
|||
|
}
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|