Pagini recente » Clasamentul arhivei de probleme | tema | Clasamentul arhivei de probleme | Profil Bankgzz | Cod sursa (job #1404160)
#include <iostream>
#include<fstream>
using namespace std;
int main()
{
ifstream ifs( "fractii.in" );
ofstream ofs("fractii.out");
int N,S,V[100],ss=0;
ifs>>N>>S;
for(int i=0;i<N;i++)
ifs>>V[i];
for(int i=1;i<=N;i++)
{
for(int j=1;j<=N;j++)
{
for(int k=1;k<=N;k++)
{
for(int l=1;l<=N;l++)
{
for(int m=1;m<=N;m++)
{
for(int n=1;n<=N;n++)
{
if (V[i]+V[j]+V[k]+V[l]+V[m]+V[n]==S)
{
ofs<<V[i]<<" "<<V[j]<<" "<<V[k]<<" "<<V[l]<<" "<<V[m]<<" "<<V[n];
ss=1;i=N;j=N;k=N;l=N;m=N,n=N;
}
}
}
}
}
}
}
if (ss==0)ofs<<"-1";
}