Pagini recente » Cod sursa (job #1696116) | Cod sursa (job #3183390) | Cod sursa (job #2648771) | Cod sursa (job #2186516) | Cod sursa (job #1330163)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int i,T;
struct cuplu
{
long a,b,c;
};
cuplu k[101];
void calcul(long a,long b, long c)
{
long x,y;
int flag=0;
if((c==0)||((a+b)>c))flag=1;
if(flag==0)
{
for(x=1;((((a*x)+(b*y))<=c)&&(flag==0));x++)
{
for(y=1;((((a*x)+(b*y))<=c)&&(flag==0));y++)
{
if(((a*x)+(b*y))==c)
{
g<<x<<" "<<y<<endl;
flag=1;
}
}
y=1;
}
}
else
{
g<<"0 0"<<endl;
}
}
int main()
{
f>>T;
for(i=1;i<=T;i++)f>>k[i].a>>k[i].b>>k[i].c;
for(i=1;i<=T;i++)calcul(k[i].a,k[i].b,k[i].c);
return 0;
}