Cod sursa(job #2047696)

Utilizator MDiana15Diana M MDiana15 Data 25 octombrie 2017 10:01:56
Problema Algoritmul lui Euclid extins Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.51 kb
#include <fstream>

using namespace std;
ifstream f("euclid.in");
ofstream g("euclid.out");
int a,b,c,i,n,d,x,y;
int euclid1(int a,int b,int &x,int &y)
{
    if(b==0)
    {
    x=1;
    y=0;
    return a;
    }
    int x0,y0;
    d=euclid1(b,a%b,x0,y0);
    x=y0;
    y=x0-(a/b)*y0;
    return d;

}
int main()
{

    f>>n;
    for(i=1;i<=n;i++)
    {
    f>>a>>b>>c;
    d=euclid1(a,b,x,y);
    if(c%d)g<<"0"<<" "<<"0"<<'\n';
    else g<<x*(c/d)<<" "<<y*(c/d)<<'\n';
    }
    return 0;
}