Pagini recente » Cod sursa (job #1247698) | Cod sursa (job #1656917) | Cod sursa (job #1092606) | Cod sursa (job #1691085) | Cod sursa (job #2989114)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("platforma.in");
ofstream out("platforma.out");
int v[15005];
long long nr[15005];
int opt;
int main()
{
int n;
in>>opt;
if(opt==1)
{
in>>n;
for(int i=1; i<=n; i++)
in>>v[i];
bool ok=1;
if(v[1]!=1)
out<<0;
else
{
for(int i=2; i<=n; i++)
{
if(v[i]==i && v[i+1]==i )
{
int rep=i;
for(int j=rep; j<=2*rep-1; j++)
{
if(v[j]!=v[rep])
{
ok=0;
}
i++;
}
i--;
}
else if(v[i]!=i)
ok=0;
}
out<<ok;
}
}
else if(opt==2)
{
in>>n;
for(int i=1; i<=n; i++)
nr[i]=1;
for(int i=3; i<=n; i++)
for(int j=i/2-(i+1)%2; j>=1; j--)
{
nr[i]+=nr[j];
}
out<<nr[n];
}
else if(opt==3)
{
int ord,x;
in>>n;
in>>ord;
for(int i=1; i<=n; i++)
{
int x=i;
for(int j=x; j<=2*x-1; j++)
{
v[j]=x;
i++;
}
i--;
}
for(int i=1; i<=n; i++)
cout<<v[i]<<" ";
}
else if(opt==4)
{
}
return 0;
}