Cod sursa(job #466629)

Utilizator MKLOLDragos Ristache MKLOL Data 27 iunie 2010 12:22:32
Problema Numarare Scor 10
Compilator cpp Status done
Runda Stelele Informaticii 2010, clasele X-XII, Ziua 1 Marime 0.56 kb
#include<stdio.h>
#include<bitset>
using namespace std;

bitset<10101> best[10101];

int N,v[10101];
long long rez;

int main()
{
freopen("numarare.in","r",stdin);
freopen("numarare.out","w",stdout);
scanf("%d",&N);
for(int i=1;i<=N;++i)
    scanf("%d",&v[i]);
for(int i=1;i<N;++i)
{
    best[i][i+1]=1;
    ++rez;
}
for(int i=3;i<=N;i+=2)
    for(int j=1;j<=N;++j)
    {
        if(best[j+1][j+i-1]==1)
            if(v[j]+v[j+i]==v[j+1]+v[j+i-1])
                {
                    ++rez;
                }
    }
    printf("%lld\n",rez);
}