Cod sursa(job #2148863)

Utilizator RaKaRe99Lodina Razan RaKaRe99 Data 2 martie 2018 08:47:56
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.82 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("loto.in");
ofstream g("loto.out");
int main()
{
    unsigned long long i,n,s,cat,r,v[10],nr;

    f>>n>>s;

    for(i=1; i<=6; i++)
        v[i]=n;

    if(n*6<s)
        g<<-1;
    else
    {
        nr=n*6-s;
        cat=nr/6;
        r=nr%6;

        if(r+cat<n)
        {
            for(i=1; i<=6; i++)
                v[i]=v[i]-cat;
            v[1]=v[1]-r;
        }
        else
        {
            i=1;
            while(r!=0)
            {
                r--;
                v[i]=v[i]-1;
                i++;
            }
            for(i=1; i<=6; i++)
                v[i]=v[i]-cat;
        }
    }
    if(n*6>=s)
        for(i=1; i<=6; i++)
            g<<v[i]<<" ";
    f.close();
    return 0;
}