Cod sursa(job #1512917)

Utilizator frentionutFrent Ionut frentionut Data 28 octombrie 2015 19:35:31
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 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;
    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]<<" ";
}