Cod sursa(job #289684)

Utilizator alia_deiCristina Sirbu alia_dei Data 26 martie 2009 21:44:35
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include<fstream.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";
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;
k--;
}
g.close();
f.close();
return 0;
}