Cod sursa(job #3358440)
| Utilizator | Data | 16 iunie 2026 19:04:07 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include<fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long t,a,b,c;
long long euclid(long long a,long long b,long long &x,long long &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
long long x0,y0;
long long d=euclid(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
return d;
}
int main()
{
fin>>t;
while(t--)
{
fin>>a>>b>>c;
long long x,y;
long long d=euclid(a,b,x,y);
if(c%d)
{
fout<<"0 0\n";
continue;
}
x*=c/d;
y*=c/d;
fout<<x<<" "<<y<<"\n";
}
return 0;
}
