Cod sursa(job #2974496)
| Utilizator | Data | 4 februarie 2023 09:59:05 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long long a1,b1,c1,d1,x1,y1,n;
void euclid(long long a, long long b, long long &d, long long &x, long long &y){
if(b==0){
d=a; x=1; y=0;
}
else{
long long x0,y0;
euclid(b,a%b,d,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
f>>n;
for(int t=0;t<n;t++){
f>>a1>>b1>>c1;
euclid(a1,b1,d1,x1,y1);
if(c1%d1==0)
g<<x1*(c1/d1)<<" "<<y1*(c1/d1)<<'\n';
else
g<<"0 0"<<'\n';
}
return 0;
}
