Cod sursa(job #2055909)
Utilizator | Data | 3 noiembrie 2017 22:01:51 | |
---|---|---|---|
Problema | Loto | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 1.58 kb |
#include <iostream>
#include <fstream>
using namespace std;
long suma(int b[])
{
long sum=0;
for(int i=0;i<6;i++)
sum+=b[i];
return sum;
}
int main()
{
int N;
long S;
int a[100];
ifstream fin("loto.in");
fin >> N >> S;
for(int i=0;i<N;i++)
fin >> a[i];
fin.close();
int b[6];
for(int i=0;i<6;i++)
{
b[i]=1;
}
int ok;
while(suma(b)!=S)
{
if(b[5]==N)
{
if(b[4]==N)
{
if(b[3]==N)
{
if(b[2]==N)
{
if(b[1]==N)
{
if(b[0]==N)
ok=1;
else
b[0]++;
}
else
b[1]++;
}
else
b[2]++;
}
else
b[3]++;
}
else
b[4]++;
}
else
b[5]++;
}
ofstream fout("loto.out");
if(ok==1)
{
fout << -1;
}
else
{
for(int i=0;i<6;i++)
fout << b[i] << " ";
}
fout.close();
return 0;
}