Cod sursa(job #1512933)

Utilizator frentionutFrent Ionut frentionut Data 28 octombrie 2015 19:48:36
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.52 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    int a[10];
    long long N,S,x,p,i;
    ifstream f("loto.in");
    ofstream g("loto.out");
    f>>N>>S;
    x=N;
    p=0;
    if(S<=6*N){
    for(i=1;i<=5;i++){
        if(S-p>=(x-1)*2 && S-p<(x-1)*3){
            x--;
            a[6-i+1]=x;
            p=p+x;
        }
        else{
            a[6-i+1]=x;
            p=p+x;
        }
    }
    a[1]=x;
    for(i=1;i<=6;i++)g<<a[i]<<" ";
    }
    else g<<"-1";
}