Cod sursa(job #3249919)

Utilizator Rares0netOnet Rares-Petru Rares0net Data 18 octombrie 2024 18:49:41
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.12 kb
//Rares 0net
using namespace std;
using ULL=unsigned long long;
#ifdef RS
#include<d:\Rares0.hpp>
#else
#include<vector>
#include<fstream>
#include<algorithm>
const string N_file="euclid3";
ifstream fin(N_file+".in");
ofstream fout(N_file+".out");
#define cin fin
#define cout fout
#endif
#define endl '\n'
#define INF 0x3f3f3f3f
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
void EuclidExtins(int a, int b, int &d, int &x, int &y)
{
    if(b==0)
    {
        x=1;
        y=0;
        d=a;
        return;
    }
    int x1, y1;
    EuclidExtins(b, a%b, d, x1, y1);
    x=y1;
    y=x1-(a/b)*y1;
}
int n;
int a, b, c;
void Solve()
{
    cin>>n;
    for(int i=1; i<=n; ++i)
    {
        cin>>a>>b>>c;
        int x, y, d;
        EuclidExtins(a, b, d, x, y);
        if(c%d!=0)
            cout<<"0 0\n";
        else
        {
            x*=c/d;
            y*=c/d;
            cout<<x<<' '<<y<<'\n';
        }
    }
}
main()
{
    Solve();
}