Cod sursa(job #1342277)

Utilizator bogdan10bosBogdan Sitaru bogdan10bos Data 13 februarie 2015 18:53:27
Problema Algoritmul lui Euclid extins Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.81 kb
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>

#define INF (1<<30)
#define mod 666013

using namespace std;
typedef long long LL;
LL t, a, b, c, d, x, y;
int E(LL a, LL b)
{
    if(b==0)
    {
        x=1;
        y=0;
        return a;
    }
    LL d=E(b, a%b);
    LL yy=y;
    y=x-y*(a/b);
    x=yy;
    return d;
}
int main()
{
    freopen("euclid3.in", "r", stdin);
    freopen("euclid3.out", "w", stdout);
    scanf("%lld", &t);
    while(t--)
    {
        scanf("%lld%lld%lld", &a, &b, &c);
        x=y=0;
        d=E(a, b);
        if(c%d)
            printf("0 0\n");
        else
            printf("%lld %lld\n", x*c/d, y*c/d);
    }
    return 0;
}