Untitled

 avatar
user_0483151
plain_text
5 months ago
980 B
3
Indexable
#include <bits/stdc++.h>
#define endl '\n'
#define maxn 1005
#define TASK bai1
#define For(i,a,b) for ( int i = a; i <= b; i++ )
#define Ford(i,a,b) for ( int i = a; i >= b; i-- )
#define MOD 10000000

using namespace std;

double a[10],b[10], kq[10][10] ;
int ans;

void inp() {
    For(i,1,3) cin >> a[i] ;
    For(i,1,3) cin >> b[i] ;
}

bool check(int i) {
    kq[i][i] = 0;
    For(j,1,3)
        if ( j != i ) {
            kq[i][j] = a[j] -  ( a[i] / b[i] )*b[j] ;
            if ( kq[i][j] < 0 ) {
                return false;
                break ;
            }
        }
    return true;
}

void solve() {
    For(i,1,3) if ( check(i) ) {
        ans = i;
        break ;
    }
    For(i,1,3) cout << fixed << setprecision(6) << kq[ans][i] << " " ;
}

int main()
{
    ios_base:: sync_with_stdio(0);
    cin.tie(0);
    if(fopen("bai1.inp","r")){
        freopen("bai1.inp","r",stdin);
    }
    inp();
    solve();
}
Leave a Comment