Hi , i got a task , that was for the olympiad of my country in informatics and i wanted to solve a few tasks , and i started with one , it was fairly easy to figure it out , and i easily coded it , and it works , its great , yeah but the fun ends anfte the enterd number is 88 or more than i got no output and i dont knw the reason so i would like to find it out but its allready 36 hours sice i started asking and searchy why the heck... so the input is a simple two line input
the number n
and the number m wich is 1 or 2.
my code looks like this
I also tried it with vectors but no result from it either.I would appriciate youre help and thanks.Code:#include <fstream>
using namespace std;
int main()
{
long int n,m,rj,l,x;
bool used[n];
ifstream in("koder.in");
ofstream out("koder.out");
in>>n;
in>>m;
for (int i=1;i<=n;i++)
{used[i]=false;}
switch (m){
case 1:
l=n%3;
rj=n/2;
l=1-l;
while (rj!=1)
{
for (int j=2;j<=n;j+=2)
{
if (used[j]==true)
{continue;}
else
{
if(rj==1)
{break;}
if(l==0)
{
rj-=1;
used[j]=true;
l=1;
}
else
{
l=0;
continue;
}
}
}
}
for (int j=2;j<=n;j+=2)
{
if (used[j]==false)
{out<<j<<endl;
}
}
break;
case 2:
l=n%3;
rj=n/2;
l=1-l;
while (rj!=1)
{
for (int j=1;j<=n;j+=2)
{
if (used[j]==true)
{continue;}
else
{
if(rj==1)
{break;}
if(l==1)
{
rj-=1;
used[j]=true;
l=0;
}
else
{
l=1;
continue;
}
}
}
}
for (int j=1;j<=n;j+=2)
{
if (used[j]==false)
{out<<j<<endl;
}
}
break;
}
in.close();
out.close();
return 0;
}
