Pagini recente » Cod sursa (job #1221810) | Cod sursa (job #2642865) | Cod sursa (job #565625) | Cod sursa (job #2699950) | Cod sursa (job #2265260)
#include <fstream>
#include <iostream>
#include <cmath>
using namespace std;
ifstream fin("aib.in");
ofstream fout("aib.out");
int Tree[270005], imax;
int build_Tree(int i, int n)
{
int inext = i + pow(2, n-1) + (i - pow(2, n-1));
if(inext > imax) fin >> Tree[i];
else Tree[i] = build_Tree(inext, n+1) + build_Tree(inext + 1, n+1);
return Tree[i];
}
int max2n(int n)
{
int x = 1;
while(2 * x <= n) x *= 2;
return x;
}
int update_Tree(int a, int b)
{
}
int main()
{
int m, n, a, b, t, i;
fin >> n >> m;
a = max2n(n);
imax = 2 * a - 1 + 2 * (n - a);
build_Tree(1, 1);
fout << "Test memorie";
return 0;
}