Pagini recente » Cod sursa (job #2320918) | Cod sursa (job #2728955) | Cod sursa (job #2072010) | Cod sursa (job #1284465) | Cod sursa (job #1412773)
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
int n,s,i,v[110],max;
ifstream in("loto.in");
ofstream out("loto.out");
in>>n>>s;
for(i=1; i<=n; i++)
{
in>>v[i];
}
do
{
max=0;
for(i=1; i<=n; i++)
{
if (max<v[i]&&v[i]<=s) max=v[i];
}
if (max==0)
{
cout<<"-1";
break;
}
for(i=1; i<=s/max; i++)
{
out<<max<<" ";
}
s=s%max;
}while (s);
}