Pagini recente » Cod sursa (job #2286966) | Cod sursa (job #1021879) | Cod sursa (job #938467) | Istoria paginii runda/leulloe2/clasament | Cod sursa (job #3276976)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("numarare.in");
ofstream fout("numarare.out");
int n, a[100003], cnt, s;
int main()
{
int i, x, y;
fin >> n;
for (i = 1; i <= n; i++)
fin >> a[i];
for (i = 1; i < n; i++)
{
x = i;
y = i + 1;
s = a[x] + a[y];
while (x >= 1 && y <= n && a[x] + a[y] == s)
{
x--;
y++;
}
x++;
y--;
cnt += (y - x + 1) / 2;
}
fout << cnt << "\n";
return 0;
}