Pagini recente » Cod sursa (job #2638388) | Cod sursa (job #507186) | Cod sursa (job #919010) | Cod sursa (job #231139) | Cod sursa (job #289707)
Cod sursa(job #289707)
#include<fstream.h>
#include<iostream.h>
ifstream f("euclid3.in");
ofstream g("euclid3.out");
float y;
long int k,m,a,b,x,ok,c,n;
int main()
{
f>>k;
while(k!=0)
{
f>>a>>b>>c;
m=a;n=b;
while(m!=n)
if(m>n) m=m-n;
else n=n-m;
x=0;
ok=0;
if(c%n!=0) g<<"0 0"<<endl;
else
while(ok==0)
{
float y = (float)(c-a*x)/b;
if(y==(int) y) ok=1;
else x++;
if(x>2000000000) x=-2000000000;
}
if(ok==1) g<<x<<" "<<y<<endl;
k--;
}
g.close();
f.close();
return 0;
}