Cod sursa(job #2050503)

Utilizator KemyKoTeo Virghi KemyKo Data 28 octombrie 2017 10:11:29
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.7 kb
#include <iostream>
#include <fstream>
#define ll long long

using namespace std;

ifstream f("euclid3.in");
ofstream g("euclid3.out");

ll n, a1, b1, c1, x, y, nr;

int gcd(ll &x, ll &y, ll a, ll b)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    else
    {
        nr=gcd(x,y,b,a%b);
        ll aux=x;
        x=y;
        y=aux-y*(a/b);

    }
    return nr;
}

void citire()
{
    int i;
    f>>n;
    for(i=1; i<=n; i++)
    {
        f>>a1>>b1>>c1;
        x=y=0;
        nr=gcd(x,y,a1,b1);
        if(c1%nr==0) g<<x*(c1/nr)<<' '<<y*(c1/nr)<<'\n';
        else g<<0<<' '<<0<<'\n';
    }
}

int main()
{
    citire();
    return 0;
}