Cod sursa(job #466636)

Utilizator gorgovanAurelian Namascu gorgovan Data 27 iunie 2010 12:28:44
Problema Numarare Scor 10
Compilator cpp Status done
Runda Stelele Informaticii 2010, clasele X-XII, Ziua 1 Marime 0.66 kb
using namespace std;
#include<iostream>
#include<fstream>
#include<cstdio>
int a[100001],N;
int b[1000][1000];
ofstream fout("numarare.out");
int memo(int x,int y)
{
    if(y-x==1) return 1;
    if(b[x][y]!=0) return b[x][y];
    else
    return b[x][y]=1+memo(x+1,y-1);
}
void solve()
{int i, j;
    for(i=1;i<=N-1;i++)
     b[i][i+1]=1;
    for(i=1;i<=N;i++)
      for(j=i+3;j<=N;j+=2)

        b[i][j]=3+memo(i+1,j-1);
    fout<<b[1][N];
}
void cit()
{int i;
    ifstream fin("numarare.in");
    fin>>N;
    for(i=1;i<=N;i++)
     fin>>a[i];
   fin.close();
}
int main()
{
    cit();
    solve();
    fout.close();
    return 0;


}