Pagini recente » Cod sursa (job #1905373) | Cod sursa (job #3236065) | Cod sursa (job #137110) | Cod sursa (job #2513490) | Cod sursa (job #3161801)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream input("euclid3.in");
ofstream output("euclid3.out");
long a, b, c, k, tempa, tempb, temp;
input>>a;
while (input>>a) {
k=0;
input>>b>>c;
tempa=a;
tempb=b;
while (tempb!=0) {
temp=tempa;
tempa=tempb;
tempb=temp%tempb;
}
if(c%tempa==0) {
if(c%a==0){
output<<c/a<<" "<<0<<endl;
} else{
while ((c-k*a)%b != 0){
k=k+1;
}
output<<k<<" "<<(c-k*a)/b<<endl;
}
} else
output<<0<<" "<<0<<endl;
}
return 0;
}